← Google Interview Insights

Google·Software Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Google SWE coding round with two problems back to back. The second one had follow-ups that kept escalating and I felt like I was barely keeping up by the end.

Questions Asked (2)

Q1

You're given a text file where each line has some raw string data. Parse each line to extract a user ID and a numeric value, then store the results in a way that's efficient to query later.

Algorithms & Data Structures
Author's notes

Pretty standard parsing problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the input format and query requirements, then propose a parsing strategy that handles edge cases and a data structure optimized for the expected queries. Discuss trade-offs between different approaches and mention how you would test and scale the solution.

Pro tip: Demonstrate awareness of real-world data issues by asking about malformed lines, duplicates, and memory constraints before diving into code. This shows you think about robustness and production readiness, not just the happy path.

1. Clarify requirements

Ask about the exact format of each line, the types of queries (e.g., lookup by user ID, range queries on value), and any constraints on memory or time. This ensures you design the right solution.

2. Design parsing logic

Propose a robust parsing method (e.g., split on delimiter, regex) that extracts user ID and numeric value, handling potential errors like missing fields or non-numeric values. Discuss validation and error handling.

3. Choose data structure

Select an efficient data structure based on query patterns: a hash map for O(1) lookups by user ID, or a balanced tree for ordered queries. Consider if multiple values per user need aggregation.

4. Implement and optimize

Write clean code to parse and store data, then analyze time and space complexity. Mention potential optimizations like streaming parsing for large files or using arrays for compact storage.

5. Test and discuss scalability

Outline test cases for edge cases (empty lines, duplicates, large values) and discuss how the solution scales with file size and query load. Mention distributed processing if needed.

Key Points to Mention

  • Time and space complexity of parsing and querying
  • Choice of data structure (hash map vs. tree) and its trade-offs
  • Handling malformed or missing data gracefully
  • Memory efficiency for large files (e.g., streaming, compression)
  • Concurrency or parallelism for faster processing
  • Testing strategy including edge cases and performance benchmarks

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

Q2

Given several people's calendars, each represented as a list of days they're free, find all days where every person is available. Follow-ups: (a) generalize to days where at least P out of N people are free, and (b) given an integer X, find all consecutive windows of X days where the availability condition holds.

Algorithms & Data Structures
Author's notes

The base case I got through fine, just intersection logic.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model each person's free days as a set or sorted list, then use a frequency map (or sweep line) to count availability per day. For the base case, collect days with count equal to N; for follow-ups, adjust the threshold and handle consecutive windows with a sliding window or run-length encoding.

Pro tip: Clarify upfront whether calendars are sorted and if days are integers or dates, as this determines whether to use two-pointer intersection or a hash map. Also, mention that the window follow-up can be solved by first computing a boolean availability array and then scanning for runs of X consecutive true values.

1. Clarify assumptions and edge cases

Ask about input format (sorted? integer days? inclusive ranges?), number of people, and whether empty calendars or X > total days are possible. This shows attention to detail and avoids wrong assumptions.

2. Choose data structures and algorithm

For the base case, use a hash map to count free days across all calendars, or if sorted, use a k-way merge with a min-heap. For the P-out-of-N follow-up, the same frequency map works with a threshold. For consecutive windows, build a boolean array of days meeting the condition and then scan for runs of length X.

3. Walk through the base case solution

Explain how to compute the intersection: iterate through each person's free days, increment a count in a map, then collect days where count == N. Analyze time and space complexity.

4. Generalize to P out of N

Modify the threshold from N to P in the frequency map approach. Discuss that if P is small, other approaches like merging intervals might be more efficient, but the frequency map is simple and works for any P.

5. Handle consecutive windows of X days

First compute the set of days where the availability condition holds (e.g., all N free). Then convert to a sorted list or boolean array and use a sliding window or run-length encoding to find all windows of length X where every day is available. Discuss edge cases like overlapping windows.

Key Points to Mention

  • Time and space complexity trade-offs between hash map, sorting, and sweep line approaches.
  • Handling of unsorted calendars and potential duplicates.
  • Using a min-heap for k-way merge if calendars are sorted and we want to avoid a large frequency map.
  • For the window follow-up, the need to first reduce to a boolean array and then use sliding window or two-pointer technique.
  • Edge cases: no common days, X larger than total days, X=0, empty calendars.
  • Scalability: if number of people or days is huge, consider streaming or interval-based approaches.

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