rams
BAN USER
Questions (5)
Comments (18)
Reputation 10
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
breaking logic is not correct. How about this
private static int findMissing(int[]arr, int s, int e)
{
int m = (s+e)/2;
int expVal = arr[s]+(m-s);
if (arr[m] > expVal )
return expVal ;
if(expVal<arr[m])
return findMissing(arr,0,m);
else
return findMissing(arr, m, e);
}
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
No need to have inorder. You can split at the number which is greater than root to get the right subtree. Ex: 53214768 is preorder,
1. First make root with first element 5 as root.
2. Search for element greater than 5. Thats where your right subtree starts from.
3. 3214 is the left subtree and 768 is right subtree
4. Apply the above recursilvely to left and right subtrees.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Is it not sum(stock prices over given range) / diff in range ? Is there anything else to this ?
- rams May 10, 2015