Is This a Binary Search Tree?

  • + 7 comments

    Error: Could not find or load main class Solution . Is anyone getting this continuously while submitting ?

    • + 1 comment

      yes, i am getting the same error. did you figure it out.

      • + 1 comment

        Naah. I guess it is some backend issue in hackerrank.

        • + 3 comments

          Same error. Even you write just a return statement return true;

          it results in with same error.

          • + 1 comment

            SAME ISSUE

            • + 0 comments

              Same issue -_-

          • + 0 comments

            same here

          • + 1 comment

            The error still not fixed yet

            • + 1 comment

              Still isn't. It is a java only error others work fine though.

              • + 1 comment

                Same issue

                • + 0 comments

                  It is October 2022 and the issue is still not fixed. I worked around it by selecting Java 7 (instead of 8).

    • + 5 comments

      Some issue with Java 8 option. Try Java 7.

      • + 0 comments

        Thanks! switching to Java 7 fixed it!

      • + 0 comments

        Thanks. This needs more likes so others don't waste time trying to figure it out.

      • + 0 comments

        You are a life saver

      • + 0 comments

        Yes Java 7 fixes it out , Thank you !!

      • + 1 comment

        Java 7 seems to give the same issue now..?

        • + 0 comments

          yeah for me as well.

    • + 0 comments

      Same error. Hacker Rank pls fix it

    • + 0 comments

      Not sure why this problem has added restrictions. In other problems they used to have main method.

    • + 0 comments

      Yes. The same problem here. Can't believe they haven't fixed it in over an year.

    • + 0 comments

      2020, this is still failing! Wasted time...

    • + 1 comment

      Even after 3 years, this has not been fixed yet. How can we raise a flag regarding this?

      • + 0 comments

        Use java 7. I tried below code, it is passing with custom test case with SAME DATA but fails for same data( 5 test failing) in their automation. Not sure why hacker rank guys are not fixing it...

        boolean checkBST(Node root) {
            if (null == root){
                return true;
            }
            //System.out.println("Processing..." + root.data);
            boolean ret = true;
            if (null != root.left){
                if (root.left.data >= root.data){
                    ret = false;
                    //System.out.println("NOT_OK:Left is bigger or equal:" + root.left.data);
                } else {
                    //System.out.println("OK:Left is small:" + root.left.data);
                }
            }
            if (null != root.right){
                if (root.right.data <= root.data){
                    ret = false;
                    //System.out.println("NOT_OK:Right is smaller or equal:" + root.right.data);
                } else {
                    //System.out.println("OK:Right is big:" + root.right.data);
                }
            }
            //if false return here
            if(!ret){
                return false;
            }
        
            return checkBST(root.left) && checkBST(root.right);
        }