Amazon Interview Question for SDE-2s


Country: India
Interview Type: Written Test




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

Could you please rephrase the question in a more understandable way. Thanks!

- Dilbert Einstein May 11, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

why b[]?

- Anonymous May 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Replace A[N-1...N-1-i] by B[N-1...N-1-i] . My mistake..

- Razz May 06, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

i=0;
while(i<n1 && (n-1-i)>=0 && a[i]==b[n-1-i])
i++;

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

Do you mean the problem of finding the longest common sub string ?

- oohtj May 06, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int match(int * a, int m, int * b, int n)
{
    if(m == 0 || n == 0)
        return -1;
    
    int flag = 0, highest = -1;
    for (int i=0; i < m; i++)
    {
        int k = 0;
        int j = (n-1);
        
        while(1)
        {
            if(k <= i && j>=(n-1-i))
            {
                if(a[k] != b[j])
                {
                    flag = 1;
                    break;
                }
            } else {
                break;
            }
            
            k = k + 1;
            j = j - 1;
        }
        
        if(flag != 1)
            highest = i;
    }
    
    return highest;
}

- chaitanya.jun12 May 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

>B[N-1...N-1-i]

Do you mean B[N-1-i...N-1] or B[m-i..m] where N is the no. of elements in B and m<N?

- Anonymous May 08, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int returnValue = -1;
for(int i=0, j=b.length - 1; i<a.length, j=0; i++, j--) {
if(a[i] != b[j]) {
returnValue = i;
break;
}
}
return returnValue;

- Anonymous May 10, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for (index=0; index < A.length && index < B.length; index++) {
if (A[index] != B[B.length - index - 1]) break;
}

- Anonymous May 10, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I can not understand your question.

- oohtj May 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void maxIndex(int a[],int b[]){
		int len=b.length-1;
		for(int i=0;i<a.length&&len>=0;i++){
			if(a[i]!=b[len]){
				System.out.print("Max Index::"+(i-1));
				break;
			}
			len--;
		}
	}

- SATHISH June 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Fuck man!!!

- fuck u August 31, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

logical representation?

- KC March 02, 2014 | 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