Tip 1: Focus on time complexities.
Tip 2: Spend 20 minutes on each question: 7-8 minutes ideating, 4-5 minutes coding, and the rest discussing time and space complexities.
Tip 3: Practice writing code on a Google Doc, as you won’t have access to an IDE during the interview.
Tip 4: Write clean code with good variable names so that a non-coder can also understand what your function does.
Tip 1: Highlight only authentic projects.
Tip 2: Mention your coding profiles.
Timing: Afternoon.
Comfortable Environment.



I used a SortedList in Python:
from sortedcontainers import SortedList
class Solution:
def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]:
output = []
window = SortedList(nums[: k])
for i in range(k, len(nums)):
output.append(window[-1])
window.add(nums[i])
window.remove(nums[i - k])
output.append(window[-1])
return output
Timing: Afternoon.
Comfortable Environment.



Elements are in the level order form. The input consists of values of nodes separated by a single space in a single line. In case a node is null, we take -1 in its place.
For example, the input for the tree depicted in the below image would be :

1
2 3
4 -1 5 6
-1 7 -1 -1 -1 -1
-1 -1
Explanation :
Level 1 :
The root node of the tree is 1
Level 2 :
Left child of 1 = 2
Right child of 1 = 3
Level 3 :
Left child of 2 = 4
Right child of 2 = null (-1)
Left child of 3 = 5
Right child of 3 = 6
Level 4 :
Left child of 4 = null (-1)
Right child of 4 = 7
Left child of 5 = null (-1)
Right child of 5 = null (-1)
Left child of 6 = null (-1)
Right child of 6 = null (-1)
Level 5 :
Left child of 7 = null (-1)
Right child of 7 = null (-1)
The first not-null node (of the previous level) is treated as the parent of the first two nodes of the current level.
The second not-null node (of the previous level) is treated as the parent node for the next two nodes of the current level and so on.
The input ends when all nodes at the last level are null (-1).
The above format was just to provide clarity on how the input is formed for a given tree.
The sequence will be put together in a single line separated by a single space. Hence, for the above-depicted tree, the input will be given as:
1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1
I stored a frequency map and used DFS to traverse the array. Then stored the sum of its children for each node. While coming back, I compared the node with the sum of its children and incremented the count accordingly.
Timing: Evening
Comfortable Environment.



A subarray is a contiguous subset of an array.
The array may contain duplicate elements.
The given array follows 0-based indexing.
It is guaranteed that there exists at least one subarray of size K.
I approached the problem with a brute-force solution first and then moved on to a solution using SortedList in Python. SortedList is a list that stores elements in sorted order, with insertion and deletion operations having a time complexity of O(log N). The solution was optimal according to Python, but I was unaware of the actual time complexities and incorrectly stated that the insertion and deletion complexities were O(N), which is similar to an array. This made the overall time complexity of my solution O(N²). The interviewer was unfamiliar with SortedList, so they thought it was a suboptimal solution.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you remove whitespace from the start of a string?