[2023-10-10]Two rounds of coding in Snowflake phone interview

The two rounds of Snowflake’s technical interviews were both coding based.

The first round involved a min stack problem, which you can reference to as LC155.

The distinction though was, the interviewer explicitly stated that the pop and push operations only required a complexity of log(N), thus I directly used a sorted map to solve it. Here’s the problem:
/*
MinStack:
push(e: int) → None
pop() → Optional[int]
min() → Optional[int] O(1)
E.g.: [2, 1, 4, 1, 3]

stack [2, 1, 4, 1, 3]
map<int, int> [1, 1, 2, 3, 4]
maintain min
min(): O(1)
pop(): O(log(N))
push(): O(log(N))
*/

Moreover, there was a small follow-up on how to solve the race condition, and I wrote some mutex locks for it.

During the second round:
Constructing a binary tree from an array was required
[0, null, 1, 2, 3]
0
/
null 1
/
2 3
/
4
follow up:
Check sub tree
a: 0
/
1 null
/
4 3
valid b: 0
/ \ \
1 5 6 7
/
3 4
invalid b: 0
/ \ \
1 5 6 7
‍‍‌‌‍‌‌‍‌‌‍‌‍‍‍‍‌‍‌/
4 8

Overall, these were quite standard LeetCode problems with a slight level of difficulty.

Fingers crossed for some good news~

The above content is collected through the Internet, translated and processed by GPT.