Amazon Interview Question for Backend Developers


Country: United States




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

Well, this involves shifting elements. Now, we have two choices: either move (start:end) indexes to newIndex or move (end+1:newIndex) to before start. While performing operations, we can decide which one is more efficient.

Complexity would be O(min(end - start + 1, newIndex - end))

- Anonymous July 01, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

There are two choices to move the records whenever someone dragdrops (start:end) records. We could move (start:end) to after newIndex or we could move (end+1:newIndex) to before start. So,

if (end-start + 1 < newIndex - end) {
	Move (start:end) to after newindex
} else {
	Move (end+1:newIndex) to before start
}

Complexity: O(min(end-start + 1, newIndex - end))

- sid July 01, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It is just 1000 records. I dont see a benefit in changing the index in DB everytime user changes sorting order.

Not sure how frequently the order changes.
Why not maintain the sorting order in application cache ?

- prasadbgv July 08, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Implement the equivalent of a linked list in the database with an MVC architecture.
e.g If you are using an RDBMS like AWS' RDS, then a tuple could be represented by (item ID, Next item ID). The primary key would be the item ID.

Whatever the new order of items is by the user could be sent to a web service through the from the UI client. The server side would then run through the list by running updates on the corresponding RDS entries.

- nik July 17, 2018 | 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