Linked List Intersection - Amazon Top Interview Questions
Given two sorted linked lists l0, and l1, return a new sorted linked list containing the intersection of the two lists. Constraints n ≤ 100,000 where n is the number of nodes in l0 m ≤ 100,000 where m is the number of nodes in l1 Example 1 Input l0 = [1, 3, 7] l1 = [2, 3, 7, 9] Output [3, 7] Example 2 Input l0 = [1, 2, 3] l1 = [4, 5, 6] Output None
View Solution →Lone Integer - Amazon Top Interview Questions
You are given a list of integers nums where each integer occurs exactly three times except for one which occurs once. Return the lone integer. Bonus: solve it in \mathcal{O}(1)O(1) space. Constraints n ≤ 100,000 where n is length of nums Example 1 Input nums = [2, 2, 2, 9, 5, 5, 5] Output 9 Example 2 Input nums = [7, 1, 1, 1] Output 7
View Solution →Long Distance - Amazon Top Interview Questions
Given a list of integers nums, return a new list where each element in the new list is the number of smaller elements to the right of that element in the original input list. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input lst = [3, 4, 9, 6, 1] Output [1, 1, 2, 1, 0] Explanation There is 1 smaller element to the right of 3 There is 1 smaller element to the right of 4 There are 2 smaller elements to the right of 9 There is 1 smaller elemen
View Solution →Longest Palindromic Substring - Amazon Top Interview Questions
Given a string s, return the length of the longest palindromic substring. Constraints n ≤ 1,000 where n is the length of s Example 1 Input s = "mactacocatbook" Output 7 Explanation "tacocat" in the middle is the longest palindromic substring.
View Solution →Longest Sublist of 1s After K Sets - Amazon Top Interview Questions
You are given a list of integers nums containing 1s and 0s and an integer k. Given that you can set at most k 0s to 1s, return the length of the longest sublist containing all 1s. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 1, 1, 0, 0, 1, 0] k = 2 Output 6 Explanation We can set the two middle 0s to 1s and then the list becomes [1, 1, 1, 1, 1, 1, 0].
View Solution →