Generate Anagram Substrings - Amazon Top Interview Questions
You are given a lowercase alphabet string s. Return all substrings in s where there is another substring in s at a different location that is an anagram. Return the list sorted in lexicographic order. Constraints 1 ≤ n ≤ 100 where n is the length of s Example 1 Input s = "aba" Output ["a", "a", "ab", "ba"] Explanation We have "a" and "a" which are anagrams. Also, "ab" and "ba" are anagrams.
View Solution →Contained Interval - Amazon Top Interview Questions
You are given a two-dimensional list of integers intervals where each element is an inclusive interval [start, end]. Return whether there's an interval which contains another interval. Constraints n ≤ 100,000 where n is the length of intervals. Example 1 Input intervals = [ [1, 3], [4, 10], [4, 8], [9, 9] ] Output True Explanation [4, 10] contains [4, 8]. Example 2 Input intervals = [ [1, 3], [4, 10], [7, 12] ] Output F
View Solution →Consecutive Ones - Amazon Top Interview Questions
You are given a list of integers nums which contains at least one 1. Return whether all the 1s appear consecutively. Constraints 1 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [0, 1, 1, 1, 2, 3] Output True Explanation All the 1s appear consecutively here in the middle.
View Solution →Palindromic Integer - Amazon Top Interview Questions
Given a non-negative integer num, return whether it is a palindrome. Bonus: Can you solve it without using strings? Constraints num < 2 ** 31 Example 1 Input num = 121 Output True Example 2 Input num = 20200202 Output True Example 3 Input num = 43 Output False
View Solution →Rotate List Left by K - Amazon Top Interview Questions
Write a function that rotates a list of numbers to the left by k elements. Numbers should wrap around. Note: The list is guaranteed to have at least one element, and k is guaranteed to be less than or equal to the length of the list. Bonus: Do this without creating a copy of the list. How many swap or move operations do you need? Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 2, 3, 4, 5, 6] k = 2 Output [3, 4, 5, 6, 1, 2] Exa
View Solution →