Remove Duplicate Numbers - Amazon Top Interview Questions
Given a list of integers nums, remove numbers that appear multiple times in the list, while maintaining order of the appearance in the original list. It should use \mathcal{O}(k)O(k) space where k is the number of unique integers. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 3, 5, 0, 3, 5, 8] Output [1, 0, 8] Explanation Only [1, 0, 8] are unique in the list and that's the order they appear in.
View Solution →Collecting Coins - Amazon Top Interview Questions
You are given a two-dimensional integer matrix where each cell represents number of coins in that cell. Assuming we start at matrix[0][0], and can only move right or down, find the maximum number of coins you can collect by the bottom right corner. Constraints n, m ≤ 100 where n and m are the number of rows and columns in matrix. Example 1 Input matrix = [ [0, 3, 1, 1], [2, 0, 0, 4] ] Output 9 Explanation We take the following path: [0, 3, 1, 1, 4] Exampl
View Solution →Decode Message - Amazon Top Interview Questions
Given the mapping "a" = 1, "b" = 2, ... "z" = 26, and an encoded message message (as a string), count the number of ways it can be decoded. Constraints n ≤ 100,000 where n is the length of message Example 1 Input message = "111" Output 3 Explanation This can be decoded 3 ways: aaa, ak, and ka. Example 2 Input message = "8" Output 1 Explanation This can be only decoded one way, as h. Example 3 Input message = "12" Output 2 Expl
View Solution →Interval Overlaps - Amazon Top Interview Questions
You are given a list of closed intervals l0 and another list of intervals l1. Individually, each list is non-overlapping and are sorted in ascending order. Return the overlap of the two intervals sorted in ascending order. Constraints n ≤ 100,000 where n is the length of l0 m ≤ 100,000 where m is the length of l1 Example 1 Input l0 = [ [1, 3], [5, 6], [7, 9] ] l1 = [ [1, 4], [5, 7] ] Output [ [1, 3], [5, 6], [7, 7] ] Examp
View Solution →Next Greater Element of a Linked List - Amazon Top Interview Questions
Given a singly linked list node, replace every node's value with the first greater node's value to its right. If a node doesn't have a next greater node, set its value to 0. Constraints n ≤ 100,000 where n is the number of nodes in node Example 1 Input node = [3, 2, 4, 5] Output [4, 4, 5, 0] Example 2 Input node = [1, 1, 1, 1] Output [0, 0, 0, 0]
View Solution →