Google phone screen
Anonymous User
1315

What date is N days after date D, for example, What is the date 100 days after 2015-08-18.

Just this one.

The interviewer was nice.

Probably the worst interview I have ever given. Intiially tried an O(1) solution for first 10 minutes. But could not find the pattern. Later went for the recursive solution.

Did not even complete the code. Gave the pesudo code.

Expecting a reject.

Funnily, right after the interview I was able to think of the O(1) solution.

Convert the date to number days from 0000-00-00.

How we do that: year/4 * (365*3 + 366) + year%4 * 365 + getCumlativeDays(month) + day;

the getCumlativeDays would precompute the number of days till that month.

Add we can reverse this entire process to get back the answer.

Update: Got the call back that I am rejected and cooldown is 12 months.

Comments (9)