Amazon | Online Assessment | April 2022 | SDE3
Anonymous User
1148

Q1. Find the minimum number of days that the delivery boy will take to deliver. The delivery will be scheduled in such a way that on a given day, the boy delivers the min number of units from each pack. (I don't remember what the exact wording was but I hope that the example can help)
Example 1:
list = [1, 2, 3, 5, 6]
Day 1: [0, 1, 2, 4, 5]
Day 2: [0, 0, 1, 3, 4]
Day 3: [0, 0, 0, 2, 3]
Day 4: [0, 0, 0, 0, 1]
Day 5: [0, 0, 0, 0, 0]

Example 2:
list = [3, 1, 8]
Day 1: [2, 0, 7]
Day 2: [0, 0, 5]
Day 3: [0, 0, 0]

Example 3:
list = [2, 0, 4]
Day 1: [0, 0, 2]
Day 2: [0, 0, 0]

Q2. Given a grid where '.' means open path and '#' means blocked path, find the min distance from top left corner to the bottom right corner where 1 move is 1 unit distance and you can only move horizontally or vertically. Top left corner and bottom right corner are always going to be '.'. Return -1 if there is no path.
Example 1:
grid = ['..', '..']
return 2

Example 2:
grid = ['.#..', '#...', '....']
return -1

Example 3:
grid = ['..#.', '#.##', '...#', '....']
return 5

Comments (3)