Amazon Interview Question for Developer Program Engineers






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

while(x<m*n):

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

public static void main(String[] args) {
int A[][] = {{1,2,3,4,5,6},{7,8,9,10,11,12},{13,14,15,16,17,18},
{19,20,21,22,23,24},{25,26,27,28,29,30},{31,32,33,34,35,36}};

int size = 6;

int loop = (int) Math.ceil(size/2.0);

int rir = 0,cirl = 0,cirh = size-1;
int ridl = 1, ridh = size-1, cid = size-1;
int ril = size-1,cilh = size-2, cill = 0;
int riuh = size - 2,riul = 1, ciu = 0;

for (int i = 0; i < loop; i++) {

for (int j = cirl; j <= cirh; j++)
System.out.print(A[rir][j]+" ");

rir++;cirl++;cirh--;

for (int j = ridl; j <= ridh; j++)
System.out.print(A[j][cid]+" ");

ridl++;ridh--;cid--;

for (int j = cilh; j >= cill; j--)
System.out.print(A[ril][j]+" ");

ril--;cilh--;cill++;

for (int j = riuh; j >= riul; j--)
System.out.print(A[j][ciu]+" ");
riuh--;riul++;ciu++;
}
}

- SD October 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void printSpiral(int[] array , int size){
//Here size : is for 4 by 4 it will be 4
for(int i= size -1 , j= 0 ; i > 0 ; i-- , j++ ){
for(int k=j ; k < i ; k++) System.out.println(a[j][k]);
for(int k=j ; k < i ; k++) System.out.println(a[k][i]);
for(int k=i ; k > j ; k--) System.out.println(a[i][k]);
for(int k=i ; k > j ; k--) System.out.println(a[k][j]);
}

//Odd number of elements like 3 by 3 then will miss out on center element
if(size%2 ==1 )System.out.println(a[(size-1)/2][size-1]/2);

}

- raj November 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

wht if size of rows and column are different

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

void print_spiral(int a[][], int m, int n){
	//matrix a of size m*n
	for(int i=0;i<m;i++){
			if(l2r==-1){
				for(int j=0;j<n;j++){
					cout<<a[i][j]<<"-";
				}
			}

			if(l2r==1){
				for(int j=n-1; j>=0;j--){
					cout<<a[i][j]<<"-";
				}
			}
			cout<<endl;
			l2r*=-1;
		}
}

- djebel January 25, 2011 | Flag


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