Is This a Binary Search Tree? HackerRank Solution


Is This a Binary Search Tree? HackerRank Solution
Source : https://www.hackerrank.com/challenges/is-binary-search-tree



Source : https://www.hackerrank.com/challenges/is-binary-search-tree


Solution


// Karthikalapati.blogspot.com
/*
The Node class is defined as follows:
class Node {
int data;
Node left;
Node right;
}
*/
boolean checkBST(Node root) {
return checkBST(root, 0, 10000);
}
boolean checkBST(Node node, int min, int max) {
if (node == null) {
return true;
} else if (node.data < min || node.data > max) { // we assume BST cannot have duplicate values
return false;
} else {
return checkBST(node.left, min, node.data - 1) && checkBST(node.right, node.data + 1, max);
}
}

17 comments:

  1. 5 Star Roof Care have been providing Surrey & London quality and competitively priced roofing services for over 30 years. We offer a range of roofs for installation, from lead roofs to Flat, pitched and GRP roofs. Our roofers are fully qualified and trained to give the best possible customer service. Roof repairs Epsom

    ReplyDelete
    Replies
    1. I like Your Post This Info Is really Very Useful This imaginative business attempt, which is capably designed and presented, offers financial open doors for everyone. Q Central Mall It's a multi-reason project that is expected to shimmer in Lahore's real estate market. Present-day designing and structure may be found at the Q Central Grand Mall and Homes. I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only

      bintang4dp

      daftarbintang4dp

      bintang4dptogel

      bintang4dp jitu

      bintang4dpprediksi


      get 100% reward free of charge

      Delete
  2. Finally, you will need to develop strong marketing and customer service initiatives to attract and retain customers. If you. https://startupo.fr/question/1406/comment_partir_sa_compagnie_/

    ReplyDelete
  3. I like Your Post This Info Is really Very Useful This imaginative business attempt, which is capably designed and presented, offers financial open doors for everyone. Q Central Mall It's a multi-reason project that is expected to shimmer in Lahore's real estate market. Present-day designing and structure may be found at the Q Central Grand Mall and Homes. I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only

    bintang4dp

    daftarbintang4dp

    bintang4dp togel

    bintang4dp jitu

    bintang4dpprediksi


    get 100% reward free of charge

    ReplyDelete
  4. https://zanderwtfqb.daneblogger.com/16431019/getting-my-bintang4dp-to-work

    https://daftarbintang4dp78900.activablog.com/16408753/the-fact-about-bintang-4dp-that-no-one-is-suggesting

    https://laneociek.bloggazzo.com/16405119/an-unbiased-view-of-bintang4dp-jitu

    https://bintang4dptogel17344.ssnblog.com/16355714/daftar-bintang4dp-fundamentals-explained

    https://israeliaqft.aboutyoublog.com/18026826/new-step-by-step-map-for-bintang4dp-togel

    ReplyDelete
  5. bintang4dp

    daftarbintang4dp

    bintang4dptogel

    bintang4dpjitu

    bintang4dpprediksi


    get 100% reward free of charge
    このチュートリアルに従うことで、誰もがわずか数分でそれを取得できます

    ReplyDelete
  6. For true fans of this thread I will address is a free online! assumeworld

    ReplyDelete
  7. Really impressed! Everything is very open and very clear clarification of issues. It contains truly facts. Your website is very valuable. Thanks for sharing. Jojoy Toca Boca

    ReplyDelete
  8. There is noticeably big money to comprehend this. I assume you have made certain nice points in features also. Create 100 Premium PBN Backlinks with Dofollow

    ReplyDelete
  9. Some times its a pain in the ass to read what blog owners wrote but this site is really user pleasant! . Guest post on high da website with dofollow backlinks

    ReplyDelete
  10. The new Zune browser is surprisingly good, but not as good as the iPod’s. It works well, but isn’t as fast as Safari, and has a clunkier interface. If you occasionally plan on using the web browser that’s not an issue, but if you’re planning to browse the web alot from your PMP then the iPod’s larger screen and better browser may be important. 끝판왕벳

    ReplyDelete
  11. Promptly your blog might it goes without saying typically possibly be visible related to each one of blog site people today, mainly because aware studies and as well lab tests. intialainen evisa lentokenttä merisatamat maasatamat poistumista varten

    ReplyDelete
  12. I’m your to get many of the content, I actually unquestionably savored, I will seriously have a preference for extra details pertaining to the following, seeing as it is really excellent., Thank you created for writing. 10 styles of clothes worn in india

    ReplyDelete