OA
70 minutes, 4 problems. The first two were super easy. The third one: given an m*n array, you define a diamond by its center point and radius, compute the sum of all the numbers inside the diamond, and return the largest sum among all valid diamonds. The fourth one was street lamps: given a set of lamps, each lamp has a center c and a radius r, so the segment [c-r, c+r] is lit by that lamp. Find the coordinate of the point lit by the most lamps (if there are several, return the smallest one).
I got a perfect score, and about a week later I scheduled a 30-minute coding first round.
30 mins coding interview
There is a game board with a maze and a ball on it. The board has five states: up, down, left, right, flat. Every second, if the board is not flat and the cell next to the ball in the tilt direction (i.e. the direction the board is tilted) is not a wall, the ball moves one cell in that direction. The input is the initial maze and ball, an array of events (an event means tilting the board in some direction at some point in time), and an end time. Return the state of the maze at the end time (i.e. where the ball is in the maze). The problem was all described verbally by the interviewer, with some starter code and examples provided.
In this round I wrote the most naive simulation, stepping through every second starting from t=0. While I was writing the four direction-movement branches, the interviewer pointed out whether I could avoid copying the same logic over and over, lol. I switched to a direction array in time, and I was also able to answer how to optimize it (just iterate over the event array directly), but I got the rejection email three days later.
Discussion
Loading comments…