title-img


Repeating String - Amazon Top Interview Questions

Given a lowercase alphabet string s, return whether it's a repeating string. Constraints n ≤ 100,000 where n is the length of s Example 1 Input s = "dogdogdog" Output True Explanation "dog" is repeated. Example 2 Input s = "catdog" Output False

View Solution →

Max Product of Three Numbers - Amazon Top Interview Questions

Given a list of integers nums, find the largest product of three distinct elements. Constraints 3 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [5, 4, 1, 3, -2, -2] Output 60 Explanation We can multiply 5 * 4 * 3 Example 2 Input nums = [-3, 1, 1, 0] Output 0 Explanation We can multiply 1 * 1 * 0

View Solution →

Verify Max Heap - Amazon Top Interview Questions

Given a list of integers nums, return whether it represents a max heap. That is, for every i we have that: nums[i] ≥ nums[2*i + 1] if 2*i + 1 is within bounds nums[i] ≥ nums[2*i + 2] if 2*i + 2 is within bounds Constraints 0 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [4, 2, 3, 0, 1] Output True

View Solution →

Matrix Prefix Sum - Amazon Top Interview Questions

Given a two-dimensional integer matrix, return a new matrix A of the same dimensions where each element is set to A[i][j] = sum(matrix[r][c]) for all r ≤ i, c ≤ j. Constraints n, m ≤ 250 where n and m are the number of rows and columns in matrix matrix[i][j] ≤ 2**12 Example 1 Input matrix = [ [2, 3], [5, 7] ] Output [ [2, 5], [7, 17] ]

View Solution →

Anagram Checks - Amazon Top Interview Questions

Given two strings s0 and s1, return whether they are anagrams of each other. Constraints n ≤ 100,000 where n is the length of s0 m ≤ 100,000 where m is the length of s1 Example 1 Input s0 = "listen" s1 = "silent" Output True Example 2 Input s0 = "bedroom" s1 = "bathroom" Output False

View Solution →