Just an Intern
BAN USER
Comments (5)
Reputation 30
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
1
of 1 vote
Wait until next Friday because I bet most of them are out of office this week. If you don't hear back until then, contact your initial recruiter.
- Just an Intern December 27, 2012Comment hidden because of low score. Click to expand.
1
of 1 vote
Good answer. Couple of improvements:
1) Find the smaller array and make countMap for it.
2) In the second loop, when count == 0, it's probably better to remove the key from the map.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Not quite sure about this case: {0, 1, 2, 3, 4, 5}, N=4
Your solution will still print (0, 4), (1, 3), (2, 2) even though (2, 2) is not a correct answer. Or am I missing something?
Comment hidden because of low score. Click to expand.
0
of 0 vote
Easy... O(n) time:
int getDuplicate(int arr[]) {
int v[] = new int[arr.length];
for(int i=0; i<arr.length; i++) {
if(v[arr[i]-1]++ > 0)
return arr[i];
}
return -1;
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
1. Split the words by space and store in an array or stack
2. Print from the end (if array) or pop (if stack)
- Just an Intern January 09, 2013