codetheuniverse
BAN USER
Comments (4)
Reputation -5
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Yes, @ashot, one vote from me.
It looks to be working good.
We can call the API IsBsT(root,INT_MIN,INT_MAX). The header <limits.h> provides us with this facility.
Comment hidden because of low score. Click to expand.
0
of 0 vote
In this case, we need to understand the requirement.
I think, 1 should come only once. But if not, slight modification can help :)
Comment hidden because of low score. Click to expand.
0
of 0 vote
Hi, I have made and added the code.
The time complexity is : O(max(m,n)); where m and b is length of array a and b
/**
*Prints the equal elements
*/
private static void getCommonElements() {
int a[] = {1,1,3,4,6,9};
int b[] = {1,1,3,4,5,9};
for(int i = 0, j = 0; i < a.length && j < b.length ; ){
if(a[i] == b[j]){
System.out.println(a[i]);
i++; j++;
}
else if( a[i] < b[j])
i++;
else
j++;
}
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
I was wondering, it could be done in 3 steps.
- codetheuniverse February 26, 2013Groups {XXX,YYY,A,B}
Step 1: Weight between XXX and YYY. Find the least weight in it. Namely, X
Step 2: Weight between A and B. Find the least weight among them, Namely, A
Step 3: The least weight would be among X and A. We can try one more time, and it seems we are done. :)