Hi Leetcode community. Today I had my second round of interview after nearly 2.5 weeks of 1st round. I've posted my first round interview in the following thread : link
Question 1: A Sum Tree is a binary tree where each node's value is equal to the sum of its left and right subtree values. Validate if a given tree is sum tree or not.
26
/\ 2nd level 4+6 = 10 | 3+0 = 3
10 3 1st level 10+10 = 20 | 3+3 = 6
/\ \ 0th level 20+6 = 26
4 6 3Question 2: https://leetcode.com/problems/minimum-knight-moves/description/
Here I provided a bfs approach, however he asked me why BFS over DFS and what's the role of queue that is doing here?. So it's obviously hard to explain in english, I took a proper example and made a dry to show how BFS queue benfits over DFS in terms of time.
Question 3: He just asked me to find a to the power of b:
However interviewer gave me another edge case of a=0 b=-3, for which I didnt handle as for negative powers logic is 1.0/ans so here it'll be (1/0). Later I incorporated this change.
Overall my interview went fine, I request guidance for the 3rd round thank you.