This document outlines my experience during a technical interview for the Google University Grad 2026 role, focusing on a problem involving a monotonic stack.
I was asked a question that was a variation of the classic "Trapping Rain Water" problem.
You are given a 1D array of integers, surface, representing a height map. You are also given an array of indices, fountains, which are source points for water. Water flows from these fountains to the left and right, filling any areas lower than the fountain's height until it hits a "wall" (a point higher than or equal to the fountain) or the edge of the array. The goal is to determine the final water level across the surface.
surface = [1, 2, 3, 4]fountains = [1, 3] (Fountains at index 1 (height 2) and index 3 (height 4))Here is a breakdown of my performance during the interview, including timing and thought process.
O(N * K) where N is the number of points and K is the number of fountains.O(N) to store the water levels.O(N) because the monotonic stack approach processes each element a constant number of times.O(N) for the stack.So, do any of you have feedback for me for Round 2?
And what are key things I should improve?
Is it hire/lean hire/strong hire?