vin2502
BAN USER
Comments (3)
Reputation 20
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.
0
of 0 vote
if all the numbers are stored in an array we can do this,
i=0;
if(arr[i+1]-arr[i] >1 )
{
//means some numbers are missing..
n = arr[i+1]-arr[i];
//so the missing numbers are arr[i]+1,arr[i]+2 ...upto n-1
}
ex. 102 - 95 =7. this means 6 numbers are missing..
missing numbers are 95+1,95+2...upto 95+6
so we do this for every 2 numbers starting from 1.
Space complexity is minimal since we r doin this using the array which is already present and not using any extras DS.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
yes why cant we just do an in order traversal and check if the resulting string is sorted??
- vin2502 December 13, 2010