Collecting Disappearing Coins - Amazon Top Interview Questions
You are given a two-dimensional list of integers matrix where each matrix[r][c] represents the number of coins in that cell. When you pick up coins on matrix[r][c], all the coins on row r - 1 and r + 1 disappear, as well as the coins at the two cells matrix[r][c + 1] and matrix[r][c - 1]. Return the maximum number of coins that you can collect. Constraints n, m ≤ 250 where n and m are the number of rows and columns in matrix Example 1 Input matrix = [ [1, 7, 6, 5], [9, 9
View Solution →Symmetric Binary Tree - Amazon Top Interview Questions
Given the root to a binary tree root, return whether it is symmetric. Constraints n ≤ 100,000 where n is the number of nodes in root Example 1 Input root = [0, [2, [5, null, null], [1, null, null]], [2, [1, null, null], [5, null, null]]] Output True Example 2 Input root = [1, [2, null, null], [3, null, null]] Output False Example 3 Input root = [1, [2, null, null], null] Output False Example 4 Input root = [1, null, [2, null, null]]
View Solution →Clock Angle - Amazon Top Interview Questions
Given a clock time with hour and integer minutes, determine the smaller angle between the hour and the minute hands and floor it to the nearest integer. Note that the hour hand moves too. Bonus: When, during the course of a day, will the angle be zero? Constraints 0 ≤ hour ≤ 23 0 ≤ minutes ≤ 59 Example 1 Input hour = 12 minutes = 22 Output 121
View Solution →Rain Catcher - Amazon Top Interview Questions
You are given a list of non-negative integers nums where each element represents the height of a hill. Suppose it will rain and all the spaces between two sides get filled up. Return the amount of rain that would be caught between the hills. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [2, 5, 2, 0, 5, 8, 8] Output 8 Explanation nums[2] can catch 3 rain drops, and nums[3] can catch 5 for a total of 8. Example 2 Input nums = [2
View Solution →Bus Fare - Amazon Top Interview Questions
You are given a list of sorted integers days , where you must take the bus for on each day. Return the lowest cost it takes to travel for all the days. There are 3 types of bus tickets. 1 day pass for 2 dollars 7 day pass for 7 dollars 30 day pass for 25 dollars Constraints n ≤ 100,000 where n is the length of days Example 1 Input days = [1, 3, 4, 5, 29] Output 9 Explanation The lowest cost can be achieved by purchasing a 7 day pass in the beginning and then a 1
View Solution →