Recently interviewed for amazon sde-1 applied through referral.
OA
Two easy-medium array question.
Phone Interview.
There were two interviwers both were SDE-2 (22 batch).They introduce themselve so do I, before jumping into DSA they asked few question LP and resume based and then jump to DSA.
Question 1: Need to return a index of element from array such that every element on left side are equal or less than, and every element on right side are equal or greate than.
Firstly i come up with O(N*N) solution and then after discussion using prefix sum i was able to do in O(N) and extra space.
Question 2: You need to transform tree into sum of left child and right child but here the catch is you cant decrement root value.
ex.
50
/ \
7 2
/ \ / \
3 5 1 30
so, if we do sum 3+5=8 and 1+30=31, replace 7->8 and 2->31
but 31+8=39 which is not eqaul to 50 (you cant decrement root values).
so this is not valid sumTree.
there are many ans one could.
50
/ \
10 40
/ \ / \
5 5 8 32intially i strugle little bit (just started my prep for job switch) but then i come with solution and they were happy with the approach .
coded both question and dry run.
after this they ask me question related java and spring as well resume question. interview was for one hour but ended in one and half.