Amazon Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

en.wikipedia.org/wiki/Connected-component_labeling

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

What do you mean when you say heaviest island?

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

I want to know too.

- Anonymous May 05, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think "island" refers to a block of numbers whose sum is maximum. But still keeping the question open for Kiran to clarify.

- Learner May 05, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Two cells is a matrix will be called connected if they are adjacent on either x-axis or y-axis (but not diagonally) For. eg., a[0,0] will be connected to both cells a[0,1] and a[1,0]. But it will not connected to cell a[1,1]

For this problem, lets say, cells denoted by integer <= 0 represent Water and cells denoted by non-zero positive integer represent Land. An Island is a connected land cells. Weight of an island is the sum of all integers in that island.

1 0 0 0
1 0 1 2
2 1 0 2
0 0 0 1

In above example matrix, there are two islands { a[0,0], a[1,0], a[2,0], a[2,1] } with weight of 5 units { a[1,2], a[1,3], a[2,3], a[3,3] }, with weight of 6 units

heaviest island is { a[1,2], a[1,3], a[2,3], a[3,3] } elements with weight 6

- nitin May 10, 2012 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

int[][] tri; tri = new int[10][]; // allocate array of rows for (int r=0; r<tri.length; r++) { tri[r] = new int[r+1]; } // print the triangular array (same as above really) for (int r=0; r<tri.length; r++) { for (int c=0; c<tri[r].length; c++) { System.out.print(" " + tri[r][c]); } System.out.println("");

- Dharmesh(DB) May 04, 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