← Google Interview Insights

Google·Software Engineer·Onsite - System Design / Architecture·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Google SWE interview focused entirely on object-oriented design for a dormitory room-assignment system. Not a grinding algorithms round, more of a whiteboard design conversation where they wanted to see how you decompose a problem into classes and think about edge cases.

Questions Asked (5)

Q1

Design an object-oriented model for a dormitory room-assignment system. You have students with room-size preferences (two-person or four-person) and rooms with fixed capacities. Walk through your class design, data structures, assignment logic, and how you handle cases where a student's preference can't be satisfied.

System DesignData ModelingTechnical Trade-offs
Author's notes

I jumped straight to writing a Student class and a Room class before figuring out what actually owned the assignment logic.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then define core classes (Student, Room, Assignment) with clear responsibilities. Walk through the assignment algorithm, emphasizing how preferences are prioritized and fallback strategies when preferences cannot be met. Conclude by discussing trade-offs and potential extensions.

Pro tip: Demonstrate awareness of real-world constraints like fairness, scalability, and changing preferences by mentioning how your design could handle waitlists or room swaps. This shows maturity beyond just coding the happy path.

1. Clarify Requirements and Constraints

Ask about scale (number of students/rooms), whether preferences are strict or flexible, and if there are other constraints (e.g., gender, accessibility). This ensures your design addresses the actual problem.

2. Define Core Classes and Relationships

Identify main entities: Student (with preference), Room (with capacity), and Assignment (linking student to room). Consider using enums for room types and a manager class to coordinate assignments.

3. Design Data Structures for Efficient Assignment

Choose structures like queues for students by preference, and maps for rooms by capacity. Consider priority queues if preferences have weights, or simple lists for small scale.

4. Outline Assignment Algorithm and Fallback Logic

Describe a greedy approach: first assign students to rooms matching their preference, then handle unmatched students by placing them in available rooms of any capacity, possibly with notification or waitlist.

5. Discuss Trade-offs and Extensions

Mention trade-offs like simplicity vs. optimality, and potential improvements such as using matching algorithms for fairness, or allowing dynamic reassignment.

Key Points to Mention

  • Encapsulation of student preferences and room capacities in separate classes.
  • Use of enums or constants for room types (e.g., TWO_PERSON, FOUR_PERSON).
  • Assignment manager class to coordinate the process and maintain state.
  • Handling unsatisfied preferences: fallback to any available room, waitlist, or notification.
  • Consideration of fairness and scalability in the algorithm.
  • Potential for extending design to handle room swaps or preference changes.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How would your design change if students could submit a ranked list of room preferences instead of a single choice?

System DesignTechnical Trade-offs
Author's notes

Follow-up that came pretty naturally from the main question.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints of the room assignment system, then outline how ranked preferences change the matching algorithm from a simple first-choice assignment to a more complex stable matching or optimization problem. Discuss the trade-offs in terms of algorithmic complexity, fairness, and system scalability, and propose a concrete design that handles ranked lists efficiently.

Pro tip: Mention the Stable Marriage problem (Gale-Shapley algorithm) as a potential solution, but also highlight its limitations (e.g., strategy-proofness, computational complexity) and suggest alternatives like serial dictatorship or top trading cycles. This shows depth in algorithmic knowledge and awareness of real-world constraints.

1. Clarify Requirements and Constraints

Ask about the scale (number of students and rooms), whether preferences are strict or allow ties, and if there are constraints like room capacities or diversity goals. This ensures you design for the right problem.

2. Model the Problem

Formalize the assignment as a matching problem where each student has a ranked list of rooms and each room has a capacity. Identify if it's a bipartite matching with preferences.

3. Choose an Algorithm

Evaluate algorithms like Gale-Shapley for stable matching, or optimization approaches (e.g., integer programming) for maximizing overall satisfaction. Discuss trade-offs between fairness, efficiency, and computational complexity.

4. Design the System Architecture

Outline components: preference collection, matching engine, result distribution, and possibly a waitlist or reallocation mechanism. Consider scalability, fault tolerance, and data storage.

5. Address Edge Cases and Trade-offs

Discuss handling of ties, incomplete lists, dynamic changes, and strategic behavior. Compare with the single-choice system to highlight improvements and new challenges.

Key Points to Mention

  • Stable matching algorithms (e.g., Gale-Shapley) and their properties (stability, strategy-proofness for one side).
  • Computational complexity: O(n^2) for Gale-Shapley vs. NP-hardness for maximizing social welfare.
  • Fairness considerations: envy-freeness, Pareto efficiency, and how to handle ties.
  • Scalability: distributed matching, sharding by dormitory or region, and caching.
  • Trade-offs between optimality and practicality: sometimes a simple greedy approach with randomization suffices.
  • Potential for strategic manipulation: students may misreport preferences if the mechanism is not strategy-proof.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

How would you adapt the system if students register one at a time over a period of time rather than all at once in a batch?

System DesignAdaptability & Ambiguity
Author's notes

This one tripped me up a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the implications of incremental registration on data consistency, performance, and user experience. Then propose a design that handles individual registrations idempotently, scales horizontally, and maintains data integrity, possibly using queues or event-driven patterns.

Pro tip: Emphasize idempotency and decoupling: each registration should be processed independently without affecting others, and consider using a message queue to smooth out spikes and ensure reliability.

1. Clarify Requirements

Ask about expected registration rate, peak loads, and consistency requirements to understand the scale and constraints.

2. Identify Challenges

Discuss issues like race conditions, duplicate registrations, and database contention that arise with incremental registrations.

3. Propose Architecture Changes

Suggest decoupling registration processing using a queue, making operations idempotent, and scaling services horizontally.

4. Ensure Data Integrity

Explain how to use transactions, unique constraints, or optimistic locking to prevent inconsistencies.

5. Monitor and Iterate

Mention the importance of monitoring registration flow, error rates, and latency to adapt to changing patterns.

Key Points to Mention

  • Idempotent registration handling to avoid duplicates
  • Use of message queues (e.g., Pub/Sub) for asynchronous processing
  • Database scaling strategies (sharding, read replicas)
  • Eventual consistency vs strong consistency trade-offs
  • Rate limiting and backpressure to handle spikes
  • Monitoring and alerting for registration pipeline health

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

Suppose groups of friends must be placed in the same room when possible. How does that change your model and what new conflicts can arise?

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

Hardest follow-up by far.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the existing model (e.g., room assignment based on capacity or preferences) and then introduce group constraints as a clustering or graph problem. Discuss how to modify the algorithm to prioritize keeping groups together, and analyze the trade-offs and potential conflicts such as fairness, scalability, and group dynamics.

Pro tip: Acknowledge that perfect group cohesion may be impossible and propose a fallback strategy, like minimizing the number of split groups or using a scoring system. This shows you think about real-world constraints and user experience.

1. Clarify the base model

Restate the original room assignment problem: what are the inputs (rooms, capacities, individual preferences) and objectives (e.g., maximize satisfaction, minimize moves)?

2. Model groups as constraints

Represent friend groups as must-link constraints or as weighted edges in a graph, where the weight indicates the strength of the desire to be together.

3. Adapt the algorithm

Modify the assignment algorithm to handle groups, e.g., by treating each group as a super-node or by adding penalties for splitting groups in an optimization function.

4. Identify new conflicts

List potential conflicts: capacity mismatches (group too large for any room), conflicting group preferences, fairness across groups, and increased computational complexity.

5. Propose trade-offs and solutions

Suggest ways to resolve conflicts, such as allowing group splitting with minimal penalty, using approximation algorithms, or implementing a priority system based on group size or user input.

Key Points to Mention

  • Graph partitioning or clustering algorithms to keep groups together
  • Constraint satisfaction problem (CSP) formulation with hard and soft constraints
  • Scalability concerns: group constraints can make the problem NP-hard
  • Fairness: ensuring no group is consistently disadvantaged
  • User experience: handling cases where groups cannot be fully accommodated
  • Potential need for a scoring function to balance individual and group preferences

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q5

How would you make the assignment deterministic and testable so the same input always produces the same output, and what unit tests would you write to verify capacity is never exceeded?

Technical Trade-offsSystem Design
Author's notes

Felt more comfortable here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by identifying sources of non-determinism in the assignment logic, such as randomness, time, or concurrency, and propose ways to control them (e.g., seeded RNG, dependency injection, deterministic tie-breaking). Then outline a testing strategy that includes unit tests for capacity constraints under various inputs, including edge cases and stress scenarios, using mocks or fakes to isolate the assignment logic.

Pro tip: Emphasize that determinism is not just about reproducibility but also about making the system easier to debug and reason about; mention that you would use property-based testing to generate many random inputs and assert capacity is never exceeded, which catches edge cases you might miss with hand-written tests.

1. Identify Non-Determinism

List all sources of non-determinism in the assignment process, such as random number generation, system time, iteration order of unordered collections, and concurrency.

2. Make Deterministic

Propose concrete changes: use a seeded random number generator, inject a clock, sort inputs deterministically, and ensure thread-safe operations or single-threaded execution.

3. Design for Testability

Structure the code to separate assignment logic from side effects, use dependency injection for external factors, and expose pure functions where possible.

4. Write Unit Tests

Outline tests that verify determinism (same input yields same output) and capacity constraints (never exceed capacity) under normal, edge, and stress conditions.

5. Include Property-Based Tests

Suggest using property-based testing to generate random inputs and assert invariants like capacity is never exceeded and output is deterministic.

Key Points to Mention

  • Seeded random number generation for reproducibility
  • Dependency injection for time, randomness, and external services
  • Deterministic tie-breaking rules (e.g., sort by ID)
  • Unit tests for capacity constraints: empty input, exactly at capacity, over capacity, and large inputs
  • Property-based testing to assert invariants across many random inputs
  • Mocking or faking dependencies to isolate the assignment logic

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.