Google L3 Phone Screen
Anonymous User
13176

Just had my phone screen today. Got asked these two questions:

Q1: A town is building a watchtower. The watchtower is located at (0, 0). Each unit height of the watchtower has a cost H. There are N houses located at (x, y) coordinates. Each house will pay cost C if it comes under the surveillance of the watchtower. The horizontal distance covered by the watchtower is the same as it's height. Find out the max profit you can make.

Inputs:

  • N number of houses
  • list of (x, y) coordinates
  • H cost to build unit height
  • C cost each house pays the watchtower

In the beginning the watchtower was located at the origin. For the followup he said watchtower location will be provided. The (x, y) coordinates can be floats as well as H and C.

Q2:
Given two strings s1 and s2, find out if they only differ by the insertion of a phrase.

Example:

  1. The boy goes to the hospital
  2. The cute little boy goes to the hospital

'cute litte' is the added phrase everything else is the same so return True

Example:

  1. The boy is nice.
  2. The girl is nice.

-> Return False

I think I got lucky with the set of questions. First question I was able to solve in ~15 minutes. I instantly got the approach. The interviewer actually said he only had one question prepared and asked me after this if I wanted to solve another one. TIFU and I said yes but I could only come up with the approach for the second one and before I could start writing code, we ran out of time.

Comments (35)