## winner

BAN USER
Comments (7)

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.

1

of 1 vote

The question is not very clear to me .

My Approach acc to what I have understood is -

1. merge the sorted arrays (n in number) and sort them.(merge sort for the n arrays)

2. Find 'n' adjacent number in the resultant array with the condition : last_num- first_num = minimum.

Comment hidden because of low score. Click to expand.

Comment hidden because of low score. Click to expand.

0

of 0 vote

public static int find_first_missing_number(int a[],int p,int q){

int k=(p+q)/2;

if(a[k]-a[k-1]==2)

return a[k]-1;

if(a[k+1]-a[k]==2)

return a[k]+1;

if(a[k]-a[p]>(k-p))

return find_first_missing_number(a,p,k-1);

else

return find_first_missing_number(a,k+1,q);

}

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.

Open Chat in New Window

Dynamic Programming :

- winner March 27, 2015Opt[i] is the number of steps(rules) required between i and 100

Base cases:

Opt[100]=0

Opt[i]=j if ith position has a ladder and j is the other end of ladder, similarly for snake too

recursive rule

Opt[i]=max(1+Opt(k)) { 0< k < 18}

Assuming that we can get min of 1 and max of 17 (6+6+5) in one rule

Find Opt[1]