Amazon Interview Report
- 0of 0 votes
AnswerI dont remember the exact problem anymore. but the problem's solution included going through an array and at every step taking 2 minimum element and adding the result. this also includes the result itself.
- Desi May 13, 2019 in United States for Robotics
so lets say for following array:
2,54,4,10,1,7
you first take 1 and 2 and add
then add the result 3 to the array
so now your array looks like :
3,54,4,10,7
then you take 3 and 4 and add them and add result back
I basically used a heap where i take two mins and add them and add the result back to heap.
I have give amazon online test twice in last 8 months and both the times the first question was about heaps and second something about finding shorted path in a grid between two cells| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 0 votes
AnswersThe problem was very similar to the problem from geeksforgeeks:
- Desi May 13, 2019 in United States for Robotics
Shortest distance between two cells in a matrix or grid
Given a matrix of N*M order. Find the shortest distance from a source cell to a destination cell, traversing through limited cells only. Also you can move only up, down, left and right. If found output the distance else -1.
instead of source and destination, they asked for robot to be able to get rid of obstacle at a certain cell.
I have give amazon online test twice in last 8 months and both the times the first question was about heaps and second something about finding shorted path in a grid between two cells| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm