We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
With your comment, I coded the following solution in python3:
flag=Truepre=-1# As all data are >= 0 so set pre = -1definOrder(root):globalflag,preifroot.left:inOrder(root.left)ifpre<root.data:pre=root.dataelse:flag=Falsereturnifroot.right:inOrder(root.right)defcheck_binary_search_tree_(root):inOrder(root)globalflagreturnflag
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Is This a Binary Search Tree?
You are viewing a single comment's thread. Return to all comments →
My original solution is:
With your comment, I coded the following solution in python3: