@@ -0,0 +1,1108 @@
+/**%0A * Definition for a binary tree node.%0A * public class TreeNode %7B%0A *     int val;%0A *     TreeNode left;%0A *     TreeNode right;%0A *     TreeNode(int x) %7B val = x; %7D%0A * %7D%0A */%0A%0A// Given a binary search tree and a node in it, find the in-order successor of that node in the BST.%0A%0A// The successor of a node p is the node with the smallest key greater than p.val.%0A%0Aclass Solution %7B%0A    public TreeNode inorderSuccessor(TreeNode root, TreeNode p) %7B%0A        if (p.right != null) %7B%0A            return findMin(p.right);%0A        %7D%0A        %0A        TreeNode successor = null;%0A        TreeNode curr = root;%0A        while (curr != null) %7B%0A            if (curr.val %3E p.val) %7B%0A                successor = curr;%0A                curr = curr.left;%0A            %7D else if (curr.val %3C p.val) %7B%0A                curr = curr.right;%0A            %7D else %7B%0A                break;%0A            %7D%0A        %7D%0A        %0A        return successor;%0A    %7D%0A    %0A    private TreeNode findMin(TreeNode p) %7B%0A        TreeNode curr = p;%0A        while (curr.left != null) %7B%0A            curr = curr.left;%0A        %7D%0A        %0A        return curr;%0A    %7D%0A%7D%0A

Create InorderSuccessorInBST.java