Phone Screen 1 -
The interviewer was liitle lat and directly jumped to the question and I was asked the question based on probability -
Consider a class as a grid of size N * M. Students pass notes to their adjacent students.
Given p = probability of a student getting caught when passing notes to a adjacent
student in same row.
q = probability of a student getting caught when passing notes to a adjacent
student in same column.
Here p and q are given for first row. as we go down the row the probability p and q
reduce by 2.
let p = 0.5, q = 0.2;
in row 1, p = 0.5, q = 0.2
in row 2, p = 0.5/2, q = 0.2/2
in row 3, p = (0.5/2)/2, q = (0.2/2)/2
Now we are given a path (r1, c1) -> (r2, c2) ... (rk, ck) (Note: any two
consecutive cells in the path are adjacent(left/right/up/down)).
We have to calculate the probability of not getting caught if we start from
(r1, c1) and end at (rk, ck) following the path given.
I think it was a very hard problem as it was really ambigous and we need to find the formula first and then write the code.
Interviewer didn't explained the problem and it took me some time to understand the problem properly, after that after a few hints i was able to find the formula, he asked me to code for it. Since very less time(6-7 minutes) was there so i tried my best to code it fast but i guess couldn't dry run the code. As soon as i completed the code for it he came up the follow up -
if we are given coordinates of startting and ending cell instead of path then how
will you calculate the maximum probability to reach (rk, ck) from (r1, c1) using only
Left, RIght, Up, Down moves.
He only asked my the data structure to use, so i proposed him the Dijkrats algorithm and told him the complexity.
Feedback i got -
The interviewer was happy that i was able to think of DS quickly for the follow up but the first round they said they have concerns around the bugs in the code and the correction of formula.
But they gave me the chance to do one more phone screen round.
Phone Screen 2 -
1st question -
Question was formulated differently and was exactly like - https://leetcode.com/problems/find-and-replace-in-string/
I was able to think for the solution and explained him the approach and code it.
2nd Question -
Similar to this question - https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels/
I have point in form of (x,y) coordinate and functions like
add()
remove()
findBoundedBox()
I proposed him to add the points in a map and find the minx,miny,maxx,maxy.
The solution complexity accepted is logn.
Interviewer didn't expect that i would come with the approach so quickly and he told me so.
Recruiter told me the next day that i have passed and wanted me to go for onsite.
Preparing for onsite now.