Adobe Interview Question for MTSs


Country: India
Interview Type: In-Person




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

//1
//11
//121
//1331
//14641
//15101051

#include <stdio.h>
#define MAX 10
int main()
{

for(int y = 0; y < MAX; y++)
{
int c = 1;
for(int x = 0; x <= y; x++)
{
printf("%d",c);
c = c * (y - x) / (x + 1);
}
printf("\n");
}
printf("\n");
return 0;
}

- madmonkey October 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

c=c*y-((x-1))/(x-1+1) => c=c*(y-x+1)/x

- Anonymous October 12, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

public static void pasqal(int r){
		for(int i = 0; i < r ; i++)
			System.out.print(fact(r-1) / (fact(i)*fact(r-1-i)));
	}
	
	public static int fact(int i){
		return (i < 2) ? 1 : i * fact(i-1);
	}

- avico81 October 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You generate (R choose k) in terms of (R choose k-1).

Possible code:

// Row R: (R choose 0), (R choose 1), ..(R Choose R).
    
List <ulong > PascalRow(uint R) {
    uint j = 1;
    ulong coeff = 1;
    List <ulong> coeffs = new List<ulong>();
    coeffs.Add(coeff);
    while (j <= R) {
        coeff = (coeff*(R-j+1))/j;
        coeffs.Add(coeff);
    }
    return coeffs;
}

- Loler October 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

There is a j++ missing.

- Anonymous October 05, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote
ez: {{{for n=1:N }}} {{{ for k=1:n}}} {{{ combin(n,k)}}} {{{ end for go down one row end for function combin factorial(n)/factorial(k)/factorial(n-k) - Gidi October 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void pascalTriangle(int n)
{
    int **a=NULL;
    a = (int **)malloc(sizeof(int *) * n);
    for(int i=0;i<n;i++)
    {
        int * row=(int *)malloc(sizeof(int) * (i+1));
        row[0]=1;
        for(int j=1;j<i;j++)
        {
            row[j]= a[i-1][j-1]+a[i-1][j];
        }
        row[i]=1;
        a[i]=row;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    for(int i=0;i<n;i++)
        free (a[i]);
    free(a);
}

- Saravana October 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int p_row[2][20]={0};
p_row[0][9]=1;
p_row[1][9]=1;
for(int i=0; i<10;i++) {
for(int j=1; j<19; j++){
/*print current row*/
if(p_row[i%2][j]==0)
cout<< " ";
else
cout << p_row[i%2][j];
/*prepare next row*/
p_row[(i+1)%2][j]=p_row[i%2][j-1]+p_row[i%2][j+1];
}

cout <<endl;
}

- Qamar Alam December 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void printPascalsTriangle(int n)
{
if(n == 0)
return;
int a[n][n];
a[0][0] = 1;
cout <<a[0][0]<<endl;
for(int i=1;i<n;i++)
{
a[i][0] = 1;
cout <<a[i][0]<<" ";
for(int j = 1;j < i;j++)
{
a[i][j] = a[i-1][j]+a[i-1][j-1];
cout <<a[i][j]<<" ";
}
a[i][i] = 1;
cout <<a[i][i]<<endl;
}
}

- Vijay negi May 10, 2017 | 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