Just finished one of the first Google 2027 Intern OAs today. There were two coding problems, and neither felt particularly difficult. The main challenge was understanding the exact conditions before jumping into a standard template.
The first problem was a greedy problem with a binary-search/LIS connection. The second was a classic subset-sum problem that could be solved with 0/1 Knapsack DP.
Overall, the OA felt fairly fundamental, but small details in the wording mattered a lot. Here’s a breakdown of both problems and the approaches that worked.
Q1: Minimum Number of Rows for Students
Problem Overview
You are given an array A representing the heights of students arriving in order.
For each student:
- If there is an existing row where every student is taller than the new student, the student can join that row.
- Otherwise, a new row must be created.
The goal is to determine the minimum number of rows required.
For example:
A = [5, 4, 3, 6, 1]
The answer is 2.
The most important detail here is the phrase “every student is taller.” It is easy to accidentally interpret the condition as simply requiring the new student to be shorter than the last student in a row, but the greedy state needs to represent the shortest student currently in that row.
Approach
Think of each row as a decreasing sequence.
For each row, we only need to keep track of its current shortest student, which is effectively the row's tail.
When a new student with height h arrives, we need to find a row whose current shortest student is still taller than h. Since that student is already the shortest person in the row, everyone else in that row must also be taller than h.
To leave as much flexibility as possible for future students, we can use a greedy strategy and update the appropriate row tail to the new, shorter height.
An ordered array with binary search works well for this:
import bisect
def min_rows(A):
# tails[i] = current shortest height in row i
tails = []
for h in A:
# Find the first tail greater than h
idx = bisect.bisect_right(tails, h)
if idx == len(tails):
tails.append(h)
else:
tails[idx] = h
return len(tails)
This problem can also be viewed as a partition into decreasing chains. The minimum number of rows is closely related to the length of the longest strictly decreasing subsequence.
The key detail is the comparison direction. Because the condition says that everyone in the row must be taller than the new student, we maintain the shortest person in each row rather than simply tracking the most recently added student.
Q2: Minimize the Load Difference Between Two Servers
Problem Overview
You are given an array of process loads. The processes need to be distributed between two servers so that the difference between their total loads is as small as possible.
For example:
A = [1, 2, 3, 4, 5]
One possible partition is:
Server 1: 1 + 2 + 4 = 7
Server 2: 3 + 5 = 8
So the minimum difference is 1.
Approach
This is essentially a classic Subset Sum problem.
Let the total load be S. If we choose a subset with sum x for the first server, the second server receives S - x.
The difference is therefore:
|S - 2x|
So instead of directly searching for two partitions, we can find a subset whose sum is as close as possible to S / 2.
A standard 0/1 Knapsack feasibility DP is sufficient when the total sum is reasonably small:
def min_load_diff(A):
S = sum(A)
target = S // 2
dp = [False] * (target + 1)
dp[0] = True
for x in A:
for j in range(target, x - 1, -1):
if dp[j - x]:
dp[j] = True
for s in range(target, -1, -1):
if dp[s]:
return S - 2 * s
return S
One important OA detail is that the DP array must be updated from right to left.
If we iterate from left to right, the same element could potentially be used multiple times during a single iteration, turning the solution into an unbounded knapsack rather than a 0/1 Knapsack.
If the total sum is extremely large, techniques such as Meet-in-the-Middle could be considered. But with reasonable OA constraints, the standard DP approach is usually enough.
Key Takeaways From This Google 27 Intern OA
| Problem | Core Concept | Main Pitfall |
|---|---|---|
| Q1 | Greedy + Binary Search / LIS | Understanding “everyone is taller” rather than only comparing with the row tail |
| Q2 | 0/1 Knapsack / Subset Sum | Updating the DP array in the wrong direction |
Looking at the two questions together, neither requires an especially advanced algorithm. The bigger challenge is recognizing the underlying model and carefully following the constraints in the problem statement.
Q1 is a good example of why wording matters. The difference between “everyone in the row is taller” and “the last student is taller” completely changes how the greedy state should be maintained.
Q2 is much more familiar as a standard subset-sum problem, but the implementation detail of iterating backward in the DP array is critical.
How to Prepare for the Google 27 Intern OA
If you're preparing for the Google 2027 Intern OA, I wouldn't focus exclusively on grinding difficult problems.
It is more useful to get comfortable recognizing common patterns quickly:
- Grouping or ordering problems → Greedy / LIS
- Splitting values into two balanced groups → Subset Sum / Knapsack
- Continuous ranges → Sliding Window / Prefix Sum
- Shortest paths → BFS / Dijkstra
- Dependency relationships → Graph / Topological Sort
More importantly, don't immediately apply a familiar template just because the problem looks similar to something you've seen before.
Read the constraints first, then choose the algorithm.
That was especially important in Q1. The “every student must be taller” condition determines exactly what information needs to be maintained for each row.
Final Thoughts
Google Intern OAs don't necessarily require extremely difficult algorithms. Under a time limit, careful reading, modeling, and edge-case handling can make a bigger difference than simply knowing more advanced techniques.
Before coding, make sure you understand exactly what the problem is asking. Even if the problem looks familiar, verify that its constraints and comparison conditions are actually the same as the problems you've solved before.
Interview Preparation Resources
If you're preparing for Google, Amazon, TikTok, Stripe, Goldman Sachs, or other North American tech companies, InterviewShow is also a useful resource to check out.
InterviewShow focuses on practical interview preparation, including Online Assessments, Coding Interviews, System Design, and Virtual Onsite interviews. Going through real interview experiences can help you understand the actual question styles, interview structure, and common follow-ups for different companies before you start preparing.
For internship recruiting in particular, getting familiar with the OA format and recent question patterns early can make preparation much more targeted than simply following a generic coding-question list.
Good luck with the Google 27 Intern OA, and hopefully everyone gets through to the next round!
Top comments (0)