Google Phone Screening

google logo
google
· SWE III· Hyderabad· 4y exp· Offer
March 29, 2026 · 10 reads

Summary

I participated in a phone screening interview for Google where I was presented with a challenging coding problem involving string manipulation and time calculations.

Full Experience

I had my phone screening interview for Google. The interviewer presented me with a problem to find the closest valid time to a given reference time, where the input time could have missing digits marked by '?'.

I began by discussing my approach, which centered around a recursive backtracking method to explore all possible digit combinations for the question marks. I also explained the necessity of helper functions to validate a generated time and to calculate the difference between two times, considering the wrap-around nature of a 24-hour clock. I then proceeded to implement these functions and the main recursive logic, ensuring to handle the time constraints (00:00 to 23:59) and correctly comparing time differences.

Interview Questions (1)

1.

Closest Time with Missing Digits

Data Structures & Algorithms·Medium

Given two times (in 24-hour format), one with missing digits marked as '?', and the other with no missing digits, we want to replace all of the question marks in the first time by digits (0-9) in such a way as to obtain the time closest to the second time. The earliest possible time is 00:00 and the latest valid time is 23:59. A time X is closer to Y than Z if the difference between X and Y is smaller than the difference between Y and Z.

Examples:
1. Given givenTime = "2?:?82", and referenceTime = "23:57" the function should return "23:58".
2. Given givenTime = "?8:4?" and referenceTime = "09:00", the function should return "08:49".
3. Given givenTime = "??:??" and referenceTime = "12:00", the function should return "12:00".
4. Given givenTime = "06:34" and referenceTime = "12:00", the function should return "06:34".

Preparation Tips

Striver's

📣 Found this helpful? Please share it with friends who are preparing for interviews!

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!