Is This a Binary Search Tree?

Sort by

recency

|

905 Discussions

|

  • + 0 comments

    It says that I don't need to worry about parsing anything in C++/20 but it has no boiler plate code to parse the input, nor does it say the format of how the input will be given so I can parse it myself?

  • + 0 comments

    Java 8 - Solution class is missing. Even if I use the code from leaderboard submissions, it does not work anymore. I get this run time error "Error: Could not find or load main class Solution"

  • + 0 comments

    None of the languages I use are setup properly to work when running code?

  • + 0 comments

    My Java 8 Solution

    boolean checkBST(Node root) {
            return isBST(root, null, null);
        }
    
        boolean isBST(Node root, Integer min, Integer max) {
            if (root == null) {
                return true;
            }
            
            if ((min != null && root.data <= min) || (max != null && root.data >= max)) {
                return false;
            }
            
            return isBST(root.left, min, root.data) && isBST(root.right, root.data, max);
        }
    
  • + 0 comments
    1. traverse the array in tree.
    2. apply the recursive approach