Is This a Binary Search Tree?

Sort by

recency

|

895 Discussions

|

  • + 1 comment
    def inorder_list(root):
        values = []
        def inorder_t(root):
            if root is None:
                return
            inorder_t(root.left)
            values.append(root.data)
            inorder_t(root.right)
        inorder_t(root)
        return values
    
    def check_binary_search_tree_(root):
        if root is None:
            return
        values = inorder_list(root)
        if values == sorted(values) and len(values) == len(set(values)):
            return True
        else:
            return False
    
  • + 0 comments

    Java8: Could not find or load main class Solution Java7: passed all tests successfully

  • + 0 comments

    Very poor problem description. How should I know what's the input and what's the class structure for a Node? I am getting continiously - Node is not a valid...

  • + 1 comment

    Getting error ...saying can't find Solution class

  • + 0 comments

    I feel that this challenge could be improved if the author were to add "setup" code that transforms the STDIN into an object that can be accepted as an input parameter to the solution function that we write.

    Most HackerRank challenges, in fact, include such code.

    The idea is to allow solvers to focus their time/effort on solving the challenge itself rather than trying to parse the STDIN data.