I need help with the format of input data


  • 0
    R

    I was wondering if one could tell me the shape of the tree for this testcase for me:
    [1,2,3,4]. I do not understand the format of the input data. Thanks a lot


  • 0

    Probably their usual way. In some problems it's explained. Look here for examples, a tool and a link to a problem with description.

        1
       / \
      2   3
     /
    4

  • -1
    R

    This is a binary tree. Therefore all value grater than root will occur right side of the root node and values smaller than root will occur on the left side of the root.

    for ex - [1,2,3,4];

    so , we have to take first element as root and then construct a BST.

    therefore
    BST for [1, 2 ,3 ,4] is

                                                         1
                                                           \
                                                             2
                                                              \
                                                                3
                                                                 \
                                                                  4
    

    I hope this will help you.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.