Movie Theatres - Amazon Top Interview Questions
Given a list of time exclusive intervals for different movie showings (possibly overlapping), find the minimum number of theatres required to be able to show all movies. Constraints 0 ≤ n ≤ 100,000 where n is the length of `intervals Example 1 Input intervals = [ [30, 75], [0, 50], [60, 150] ] Output 2 Explanation [30, 75] and [0, 50] overlap. [30, 75] and [60, 150] also overlap but later on. So the max number here is 2. Example 2 Input inter
View Solution →Interval Union - Amazon Top Interview Questions
Given a two-dimensional integer list intervals representing unsorted inclusive intervals, return their union in sorted order. Constraints n ≤ 100,000 where n is the length of intervals Example 1 Input intervals = [ [0, 5], [4, 6] ] Output [ [0, 6] ] Example 2 Input intervals = [ [1, 2], [3, 4] ] Output [ [1, 2], [3, 4] ] Example 3 Input intervals = [ [5, 6], [1, 2] ] Output [ [1, 2], [5
View Solution →Level Order Binary Tree to Linked List - Amazon Top Interview Questions
Given a binary tree root, convert it to a singly linked list using level order traversal. Constraints 1 ≤ n ≤ 100,000 where n is the number of nodes in root Example 1 Input root = [1, [2, null, null], [3, [4, null, null], [5, null, null]]] Output [1, 2, 3, 4, 5] Example 2 Input root = [1, [0, null, null], [2, null, null]] Output [1, 0, 2]
View Solution →Merging Binary Trees - Amazon Top Interview Questions
Given two binary trees node0 and node1, return a merge of the two trees where each value is equal to the sum of the values of the corresponding nodes of the input trees. If only one input tree has a node in a given position, the corresponding node in the new tree should match that input node. Constraints n ≤ 100,000 where n is the number of nodes in node0 m ≤ 100,000 where m is the number of nodes in node1 Example 1 Input node0 = [0, [3, null, null], [2, [3, null, null], null]]
View Solution →Sum of Two Numbers in BSTs - Amazon Top Interview Questions
You are given two binary search trees a and b and an integer target. Return whether there's a number in a and a number in b such that their sum equals to target Constraints n ≤ 100,000 where n is the number of nodes in a m ≤ 100,000 where m is the number of nodes in b Example 1 Input a = [5, [3, null, null], [7, null, null]] b = [4, [2, null, null], [8, null, null]] target = 9 Output True Explanation We can pick 7 from a and 2 from b. Example 2 Input a =
View Solution →