Amazon OA SDE-1
Anonymous User
9454

Hello Guys,
On June 26th , I gave my online assessment for Amazon.
Duration: 105 minutes
Platform: Hackerrank

  1. Problems
    Question 1:
    Amazon Music Pair.
    Given durations of songs and the rideDuration of the bus, return the pair of songs which when added is exactly equal to rideDuration-30 seconds. You cannot repeat the song.Return the index of the songs
    Ex: RideDuration: 250
    songDurations = [100,180,40,120,10]
    ans: [2,1]
    Approach: First create hashmap to store the original indexes of the songs "map<int,vector>", vector is to store the indexes of the same duration of songs. Then sort the songDurations and use two poinetr approach to get the pair of songs.
    similar to :https://leetcode.com/problems/two-sum/

Question 2:
Demolition Robot
Given a matrix with values 0 (trenches) , 1 (flat) , and 9 (obstacle) you have to find minimum distance to reach 9 (obstacle). If not possible then return -1.
The demolition robot must start at the top left corner of the matrix, which is always flat, and can move on block up, down, right, left.
The demolition robot cannot enter 0 trenches and cannot leave the matrix.
Sample Input :
[1, 0, 0],
[1, 0, 0],
[1, 9, 1]]
Sample Output :
3
Approach: BFS traversal

  1. Workstyle Survey

  2. Feedback

Comments (5)