Solved! Leetcode 1214. Two Sum BSTs

Solved! Leetcode 1214. Two Sum BSTs
source: https://leetcode.com/problems/two-sum-bsts/ Two Sum BSTs Description Given the roots of two binary search trees, root1 and root2, return true if and only if there is a node in the first tree and a node in the second tree whose values sum up to a given integer target. Example 1: Input: root1 = [2,1,4], root2 = ...

Solved! Leetcode 1586. Binary Search Tree Iterator II

source: https://leetcode.com/problems/binary-search-tree-iterator-ii/description/ Binary Search Tree Iterator II Implement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST): BSTIterator(TreeNode root) Initializes an object of the BSTIterator class. The root of the BST is given as part of the constructor. The pointer should be initialized to a non-existent number ...

Check if a binary tree is BST

Title: A program to check if a binary tree is BST or not Source: www.geeksforgeeks.org A binary search tree (BST) is a node based binary tree data structure which has the following properties. • The left subtree of a node contains only nodes with keys less than the node’s key. • The right subtree of ...