nathgopi45
BAN USERFor success scenario, it is o(n), but in case if the given tree in not BST like either its left or right child branch has more number of levels, then we need to break the iteration and we can mention that this is not BST.
This can be done by calculating the level of the node by inorder, and once we reached the last leaf node, we can start calculating the total number of nodes that we are traversing from bottom to top, at any stage if it is against 2N -1 , then it is not BST
we can use Kth order statistics to get the first K elements near to it..
- nathgopi45 March 24, 2014Yes.. thats it.
Cool.. thanks a lot. :)
as per example 1 in the question, we are having four matching patterns , right.?
ab, aab, aaab, ab
the above four patterns are satisfying a*b .
a is occuring 0 or more times and then single 'b' is at end of the string.
so the output should be 4, right.?
s32.postimg.org/sm75dimol/hurdle1.jpg
- nathgopi45 July 30, 2016