## Phone Number Combinations - Amazon Top Interview Questions

Given a string digits containing 2 to 9 inclusive, return in sorted lexicographic order all possible strings it could represent when mapping to letters on a phone dialpad. These are the mappings on a phone dialpad: | 2 | abc | | 3 | def | | 4 | ghi | | 5 | jkl | | 6 | mno | | 7 | pqrs | | 8 | tuv | | 9 | wxyz | Example 1 Input digits = "23" Output ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]

View Solution →## Removing Parentheses - Amazon Top Interview Questions

Given a string of parentheses s, return the minimum number of parentheses to be removed to make the string balanced. Constraints n ≤ 100,000 where n is the length of s Example 1 Input s = "()())()" Output 1 Explanation We can remove the ")" at index 4 to make it balanced. Example 2 Input s = ")(" Output 2 Explanation We must remove all the parentheses.

View Solution →## Repeated Deletion Sequel - Amazon Top Interview Questions

Given a string s and an integer k, repeatedly delete the earliest k consecutive duplicate characters. Constraints k, n ≤ 100,000 where n is the length of s. Example 1 Input s = "baaabbdddd" k = 3 Output "d" Explanation First we delete the "a"s to get "bbbdddd". Then we delete the "b"s to get "dddd". Then we delete three of the four "d"s to get "d"

View Solution →## Rocketship Rescue - Amazon Top Interview Questions

You are given a list of integers weights representing peoples' weights and an integer limit representing the weight limit of one rocket ship. Each rocketship can take at most two people. Return the minimum number of rocket ships it would take to rescue everyone to Mars. Constraints n ≤ 100,000 where n is the length of weights max(weights) ≤ limit Example 1 Input weights = [200, 300, 200] limit = 400 Output 2 Explanation It would take one rocket ship to ta

View Solution →## Rotate by 90 Degrees Counter-Clockwise - Amazon Top Interview Questions

Given a two-dimensional square matrix, rotate in-place it 90 degrees counter-clockwise. Constraints n = m ≤ 250 where n and m are the number of rows and columns in matrix Example 1 Input matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] Output [ [3, 6, 9], [2, 5, 8], [1, 4, 7] ]

View Solution →