We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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);
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Is This a Binary Search Tree?
You are viewing a single comment's thread. Return to all comments →
Error: Could not find or load main class Solution . Is anyone getting this continuously while submitting ?
yes, i am getting the same error. did you figure it out.
Naah. I guess it is some backend issue in hackerrank.
Same error. Even you write just a return statement return true;
it results in with same error.
SAME ISSUE
Same issue -_-
same here
The error still not fixed yet
Still isn't. It is a java only error others work fine though.
Same issue
It is October 2022 and the issue is still not fixed. I worked around it by selecting Java 7 (instead of 8).
Some issue with Java 8 option. Try Java 7.
Thanks! switching to Java 7 fixed it!
Thanks. This needs more likes so others don't waste time trying to figure it out.
You are a life saver
Yes Java 7 fixes it out , Thank you !!
Java 7 seems to give the same issue now..?
yeah for me as well.
Same error. Hacker Rank pls fix it
Not sure why this problem has added restrictions. In other problems they used to have main method.
Yes. The same problem here. Can't believe they haven't fixed it in over an year.
2020, this is still failing! Wasted time...
Even after 3 years, this has not been fixed yet. How can we raise a flag regarding this?
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...