Making Change Sequel - Amazon Top Interview Questions
Given a list of integers denominations and an integer amount, find the minimum number of coins needed to make amount. Return -1 if there's no way to make amount. Constraints n ≤ 10 where n is the length of denominations. amount ≤ 500,000. Example 1 Input denominations = [1, 5, 10, 25] amount = 60 Output 3 Explanation We can make 60 with 2 quarters and 1 dime. Example 2 Input denominations = [3, 7, 10] amount = 8 Output -1 Explanation We can't
View Solution →Submajority Vote - Amazon Top Interview Questions
You are given a list of integers nums where each number represents a vote to a candidate. Return the ids of the candidates that have greater than \lfloor \frac{n}{3}\rfloor⌊ 3 n ⌋ votes, in ascending order. Bonus: solve in \mathcal{O}(1)O(1) space. Constraints n ≤ 100,000 where n is the length of nums. Example 1 Input nums = [2, 1, 5, 5, 5, 5, 6, 6, 6, 6, 6] Output [5, 6] Explanation Both 5 and 6 have 40% of the votes. Example 2 Input nums = [1,
View Solution →Maximal Sublist Product - Amazon Top Interview Questions
Given a list of integers nums, find the maximum product of integers in any contiguous sublist. Constraints 1 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 10, 2, 0, 3, 5] Output 20 Explanation Maximum product sublist is [1, 10, 2] and 1 * 10 * 2 = 20
View Solution →Course Scheduling - Amazon Top Interview Questions
You are given a two-dimensional integer list courses representing an adjacency list where courses[i] is the list of prerequisite courses needed to take course i. Return whether it's possible to take all courses. Constraints n, m ≤ 250 where n and m are the number of rows and columns in matrix. Example 1 Input courses = [ [1], [], [0] ] Output True Explanation We can take course 1, then course 0, and then course 2
View Solution →Uber Pool - Amazon Top Interview Questions
You are given a two-dimensional integer list requested_trips containing [start_x, end_x, num_passengers], and an integer capacity. Each requested trip asks to pick up num_passengers passenger at start_x and drop them off at end_x. You also have a car with the given capacity, and start at x = 0. Given that you'd like to pick up every passenger and can only move right, return whether you can pick up and drop off everyone. Constraints n ≤ 100,000 where n is the length of requested_trips
View Solution →