Google | L4 | Phone Screening | April 2025

Anonymous User
1533
Apr 22, 2025
Apr 29, 2025

Question:

You are given a list of cakes. The class below was not provided had to ask questions to create that.

class Cake:
    def __init__(self, x: float, y: float, side: float):
        self.x = x
        self.y = y
        self.side = side

Now you need to make horizontal cuts such that cake contained above the cut and below it is same. There was no bound on x, y or side.

NOTE: This was not the exact question instead I have simplified it here for better understanding had to ask few questions to arrive here.

Approach: Gave a brute force solution to go through each and every possible horizontal cuts and figure out the area(We all know it will result in TLE). Then came up with binary search approach. The interviewer was okay with that.

Code: Created a separate function to get the area contained above a horizontal cut since subtracting it from total area gives area below it.

Discussed the time and space complexity.

[Update]Verdict: I failed the interview and apparently the feedback was I was UNABLE to solve the problem which to me was pretty strange I dont know what more was expected. Anyways it was a lerning experience!

All the best to people who have their upcoming iterviews👍!

Comments (5)