Adobe Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

Fabnocii number f(n)

- xjshi July 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Agreed, Fibonnaci sequence. Your f(3) should be 5. Using your notation:

_123_
_13_
_23_
_2_
_12_

- Anonymous July 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

i am studied b-tech with eee branch having aggregate 58.85% is it sufficient to get a job with 40k salary?

- chiranjeevi mandava July 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Seems u r drunk :-O
It's not a site to ask for job offers. Look in glassdoor rather.

- hmm July 06, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Guys, there is one more constraint that frog should always step on the first and last steps. He can jump max one step between the first and last but can not escape first and last steps. so, in the above example for f(3): _2_, _23_, _12_ will be eliminated and answer would be only two paths: _123_ and _13_ available.

- Anonymous July 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It can be solve by recursion. Given a current step (say ith) a frog can jump to i+1 or i+2. In either case, the problem is reduced by recursion. The termination is when the frog reach the last stone or the river bank. Hence we can make the recursive call as the frog is on the previous stone (or a river bank):

boolean stones = new boolean[N];
frog(stones,0); //a frog is at the river bank.

void frog(int j){
  if(j >= N-1) print_all_steps(stones);
  else{
    stones[j] = true; //case I: jump to jth
    frog(j+1);
    stones[j] = false;//case II: don't jump to jth
    stone[j+1] = true;//case II: then it has to land on (j+1)th
    froh(j+2);
  }
}

I hope you don't need a code on print_all_steps(boolean[]) as it is clear what to do on stones[N] right :).

- Saimok July 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Saimok : above solution is great
but a small tweak needed to discard all solution that don't land the frog on the last step :)

- Coder July 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

i think ans is (2^n - 1) .... as frog either jump on nth step or it may not also , so 2 posibilities for each step ..... As frog should jump atleast one of the steps we have to exclude this case.

- pavan July 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nopes....
It can't jump over more than one step. Hence, every step can't take any of the two values. It depends on the values of previous and previous to previous step !!

- Saurabh January 22, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

//solution below does not print the paths but returns number of possible paths for a given //start index and number of stone
int pp(int n,int start)
{
int end = start+n-1;
if(start>end)return 0;
else if((start == end) || (end == start+1))return 1;
else if(end == (start+2))
return 2;
else
return pp(n-2,start+1)+pp(n-3,start+1)+pp(n-3,start+2)+pp(n-4,start+2);

}

- Amritanshu February 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

solution below does not print the paths but returns number of possible paths for a given start index and number of stone
int pp(int n,int start)
{
int end = start+n-1;
if(start>end)return 0;
else if((start == end) || (end == start+1))return 1;
else if(end == (start+2))
return 2;
else
return pp(n-2,start+1)+pp(n-3,start+1)+pp(n-3,start+2)+pp(n-4,start+2);

}

- Amritanshu February 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>

int no_path(int a[], int n, int start)
{
    static int count =0;
    if(start == n-1)
    {
        count++;
        return count;
    }
    if(start+1<n)
        no_path(a,n,start+1);
    if(start+2<n)
            no_path(a,n,start+2);

    return count;
}


 main()
  {
     int a[] = {1,2,3,4,5};
     printf("%d",no_path(a,5,0));
     getch();
  }

- Mridul Malpani April 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

whats the use of array a[] in this piece of code?

- vinay April 26, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Seems its viral...:)
As mentioned it can be solved by fibonacci.
Suppose steps are :
_ a1 a2 a3 a4 a5 ..........an_

f(n)=f(n-1)+f(n-2)
f(n-1)------frog simply goes to a1 and we are left with subproblem to find number of solutions for a2 a3 a4 a5 ....an
f(n-2)------frog can jump a1 and goes to a2,now the left subproblem is a3 a4 a5.....an

- y so serious May 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Seems its viral...:)
As mentioned it can be solved by fibonacci.
Suppose steps are :
_ a1 a2 a3 a4 a5 ..........an_

f(n)=f(n-1)+f(n-2)
f(n-1)------frog simply goes to a1 and we are left with subproblem to find number of solutions for a2 a3 a4 a5 ....an
f(n-2)------frog can jump a1 and goes to a2,now the left subproblem is a3 a4 a5.....an

- y so serious May 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class frog_problem {

public static void frog_path(int a[],int k, int n)
{
if(k==n)
{
if(issafe(a,n)==1)
{
for(int i = 0 ; i<n ;i++)
{
if(a[i]==1)
System.out.print((i+1)+" ");


}

System.out.println();

}
}
else
{
k++;
for(int j=0;j<2;j++)
{
a[k-1] = j;
frog_path(a,k,n);
}

}

}
public static int issafe(int a[],int n)
{
int i ;
for(i=1;i<n-1;i++)
{
if((a[i]==0 && a[i-1]==0) || (a[i]==0 && a[i+1]==0))
return 0;


}

return 1;
}
public static void main(String args[])
{

int n = 4;
int a[] = new int[n];
frog_path(a,0,n);


}

}

- ritrat October 26, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More