Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

not sure this is efficient but Doubly Linkedlist with additional capability(See below) could solve the problem:

Consider:
------C1 -- C2 -- C3
================
R1 || L1 -- L2 -- L3
.......||....|........|.........|
R2 || L4 -- L5 -- L6
.......||....|.........|........|
R3 || L7 -- L8 -- L9

The above diagram clearly explains L1 points L2 (next/prev element in row) and L3 (next/prev element in the column) and so on .

so the linkedlist class will be:

class node{

int data;
node *rowNext;
node *columnNext;
node *rowPrev;
node *columnPrev;

void delete row();
void delete column();
void delete element(){
//this one is tricky but a count of indices would make the deletion simpler along with updating the next elements in the current and adjacent row/column;
}

-to delete a column use columnNext to free the memory and update the rowPrev node's address everytime.
-to delete a row use rowNext free the memory and update the columnPrev node's address
-to delete an arbitrary element complex procedure [Update next and adjoint elements -- Creating a function would solve the problem]
****************************************
for the second part of the problem there is something called as DDEML (Dynamic Data Exchange Management Library).

- HuggableAtol March 12, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What came 2 my mind instantly was 2d array..But it will not allow insertion ,deletion of rows n cols easily...
so wht abt linked list of linked list??

- AJ March 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Sparse Matrix

- sk March 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

List of lists (LIL) stores one list per row, where each entry stores a column index and value.

- Larry March 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Adjacency list: because its easy to add, delete and update data in it.

- loosy.jhony March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Adjacency list: Because we are using memory for data that is stored rather than sparse matrix and because its easy to add, delete and update data in Adjacency list.

- loosy.jhony March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

How about vector of vectors? Would that be fine in this scenario?

- RookieCoder March 13, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.


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