title-img


Anagram Substrings - Amazon Top Interview Questions

Given two strings s0 and s1, return the number of substrings where s1 contains any anagram of s0. 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 = "abc" s1 = "bcabxabc" Output 3 Explanation The substrings "bca", "cab" and "abc" of s0 are permutations of "abc".

View Solution →

Shortest Sublist to Remove to Make Sorted List - Amazon Top Interview Questions

Given a list of integers nums, return the length of the shortest sublist that you can remove such that the resulting list is in ascending order. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 1, 3, 5, 4, 2, 1, 9] Output 3 Explanation If we remove [4, 2, 1], then the list would be sorted in ascending order: [1, 1, 3, 5, 9].

View Solution →

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 →