Check for BST with exactly one child of each internal nodes

Given preorder traversal of a binary tree, check if it is possible that it is also a preorder traversal of a BST,

where each internal node (non -leaf nodes) have exactly one child.

CONSTRAINTS

1 <= N <= 100

INPUT

    A : [ 4, 10, 5 ,8 ]

OUTPUT

    YES

EXPLANATION

    The possible BST is:
    
            4
             \
             10
             /
             5
              \
              8
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Check for BST with exactly one child of each internal nodes on Interview Code Editor
Hints
  • Hints are not available for this problem

Discussion


Loading...
Click here to start solving coding interview questions