Preparing for an interview? Check out Cracking the Coding Interview
Published on

Google Phone Screen | Reject

Author
  • Shared Anonymously

Hi, everyone had my Google Phone screen last week.

First question: Given a nxm, grid, find the total number of ways to go from bottom left to bottom right. Allowed directions were (i,j+1), (i+1,j+1), (i-1,j+1)
Solved it with dp. Interviewer seemed satisfied.
TC: O(nm)
SC: O(n
m)

Followup question: Let's say we add coins in the grid. Find the total number of ways such that we are able to collect all coins, starting from bottom left and reaching bottom right and following the same allowed directions as in question 1.

Came up with O(nmk), assuming there are k coins in the grid, 3D DP solution. Interviewer asked me to code it up, and said it looks good.

Interviewer ended within 40 minutes.

Feedback: Did not do a dry run, and the code wasn't space optimized.

Have a query, do we optimize when the interviewer says to? My assumption was the interviewer will ask us to think more to optimize a given problem, instead of saying LGTM .

Post the round upon thinking was able to come up with a more optimal solution for the second case, with better TC and SC, but I expected the interviewer will atleast ask me to think more.

ReportMark as Helpful