Need help with "Chef learns BST"-ECAUG204

link to the problem:

I don’t understand how to approach this problem.Can anyone help me with the approach.

Try to remember the properties of BST. There is a root node. And on the left, all values less than the key node are present and on the right, all values greater than key node are present.
So, to check whether an array presents a BST is to simply sort them in ascending order, which is also represents the inorder traversal of a BST(inorder traversal gives ascending order) and just check if there are unique elements

1 Like

thanks @ashish_kaur…i got it.

Only that much is sufficient

for _ in range(int(input())):
    if len(set(l))==n:
1 Like