Amazon SDE-1 2023/2024 Graduate | Round 2 | Banglore
3388

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

  • I was asked to introduce about me, further interviewer asked questions about my role in the team, projects I've worked on for around 15 minutes.
  • Later he provided me the following 2 DSA questions which are actually quite easy as they're standard.

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   3

Question 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.


  • So I completed these two questions in 35min, by explaining my approach, dry-run and wrote the code in bestway (as code style will be asserted).
  • We were left with around 10 minutes so he just wanted to check my edge-case detecting skills in the left over-time.

Question 3: He just asked me to find a to the power of b:

  • Took variable to calculate answer as long
  • Handled a=0 && b=0 edge case, by throwing exception
  • Handled cases like b<=0.

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.

Comments (15)