← Google Interview Insights

Google·Data Scientist·Technical Phone Screen·Senior

Senior
Jul 2026

Summary

Google Data Scientist technical screen, two fairly meaty coding problems back to back. The questions were more software-engineering-heavy than I expected for a DS role, lots of Unicode edge cases and streaming constraints that I hadn't really prepped for.

Questions Asked (3)

Q1

Write an anagram-checking function that handles Unicode normalization, ignores case/whitespace/punctuation, strips combining marks for English locales, and runs in O(n) time with O(alphabet size) extra memory without materializing the full normalized string.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The streaming constraint is what tripped me up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then outline a streaming algorithm that processes characters one by one, applying normalization and filtering on the fly while updating a fixed-size count array. Emphasize the O(n) time and O(alphabet size) space guarantees, and discuss trade-offs around Unicode normalization and locale-specific handling.

Pro tip: Mention that full Unicode normalization (e.g., NFC/NFD) can be done incrementally per character using a streaming normalizer, but for English locales, a simpler approach of stripping combining marks after NFD is sufficient and avoids buffering the entire string.

1. Clarify requirements and constraints

Ask about the expected input size, character set (e.g., English vs. multilingual), and whether normalization should be locale-specific. Confirm that O(n) time and O(alphabet size) space are hard requirements.

2. Design the streaming algorithm

Iterate over each character, apply case folding, skip whitespace/punctuation, and for English locales, decompose to NFD and drop combining marks. Update a count array (or hash map) for the resulting base characters.

3. Handle Unicode normalization incrementally

Explain that full normalization can be done per character using a streaming normalizer, but for English, stripping combining marks after NFD is sufficient. Avoid materializing the full normalized string by processing characters on the fly.

4. Compare counts and return result

After processing both strings, compare the count arrays. If they match, the strings are anagrams; otherwise, they are not. Ensure the comparison is O(alphabet size).

5. Discuss trade-offs and edge cases

Address potential pitfalls: locale-specific case folding (e.g., Turkish i), handling of emojis or non-BMP characters, and the impact of normalization on performance. Mention that the alphabet size may be large for full Unicode, but for English it's small.

Key Points to Mention

  • Unicode normalization forms (NFC, NFD) and when to use each
  • Case folding vs. lowercasing, and locale-specific rules (e.g., Turkish dotless i)
  • Stripping combining marks for English locales (e.g., removing accents)
  • Streaming processing to avoid O(n) extra memory for the normalized string
  • Using a fixed-size count array for O(alphabet size) space
  • Time complexity: O(n) for processing each string, O(alphabet size) for comparison

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

Q2

Follow-up: how would you adapt the anagram checker to handle locale-specific rules like German 'ß' expanding to 'ss', and how do you handle right-to-left scripts without breaking normalization?

Algorithms & Data StructuresTechnical Trade-offsAdaptability & Ambiguity
Author's notes

Blanked on the RTL part for a moment.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by acknowledging that anagram checking relies on character normalization and canonicalization, which must be locale-aware. Then outline a pipeline: apply Unicode normalization (NFKC/NFKD) with locale-specific tailoring, handle special cases like German ß via case folding and expansion, and ensure right-to-left scripts are processed in logical order without disrupting normalization. Emphasize that the core algorithm (sorting or counting) remains the same, but preprocessing must be robust and configurable.

Pro tip: Mention that Unicode case folding (not just lowercasing) is essential for correct anagram detection across locales, and that RTL scripts should be normalized in logical order—never visually reordered—to avoid corrupting the character sequence.

1. Clarify requirements and constraints

Ask whether the anagram checker must support all locales or just specific ones, and whether performance or memory is a concern. This shows you consider trade-offs before diving into implementation.

2. Apply Unicode normalization with locale tailoring

Use NFKC or NFKD normalization to decompose characters, then apply locale-specific rules (e.g., German ß → ss via case folding). Mention that ICU libraries provide this functionality.

3. Handle case folding and special expansions

Perform full Unicode case folding (e.g., ß → ss, ẞ → ss) rather than simple lowercasing. For other locales, consider ligatures (fi → fi) and diacritic removal if appropriate.

4. Process RTL scripts in logical order

Ensure that normalization and subsequent processing occur on the logical character sequence, not the visual order. RTL scripts like Arabic or Hebrew should be handled by the same pipeline without reordering.

5. Validate with test cases and discuss trade-offs

Test with locale-specific examples (e.g., 'straße' vs 'strasse') and RTL strings. Discuss performance implications of normalization and whether to cache normalized forms.

Key Points to Mention

  • Unicode normalization forms (NFC, NFD, NFKC, NFKD) and their use in anagram checking.
  • Locale-specific case folding, especially German ß → ss and its uppercase equivalent ẞ.
  • The importance of using ICU (International Components for Unicode) for locale-aware processing.
  • Handling of right-to-left scripts: process in logical order, avoid visual reordering.
  • Potential performance overhead of normalization and strategies like caching or precomputation.
  • Edge cases: combining characters, ligatures, and scripts without case distinctions (e.g., Chinese).

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

Q3

Implement a lazy, stable de-duplication generator that yields the first occurrence of each distinct element, supports a custom key function, and optionally treats all NaN floats as equal, in O(n) time and O(distinct keys) space.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

NaN handling is the annoying part because NaN != NaN in Python so a plain set won't catch it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: lazy generator, stable order, custom key function, NaN handling, and complexity constraints. Then design a generator that maintains a set of seen keys, yielding elements only when a new key is encountered, and handle NaN by normalizing it to a sentinel value. Finally, discuss trade-offs and edge cases.

Pro tip: Emphasize that using a set for seen keys gives O(1) average lookup, but mention that if keys are unhashable, you might need a different approach. Also, highlight that NaN handling requires special care because NaN != NaN, so you must check for NaN explicitly.

1. Clarify Requirements and Constraints

Confirm that the generator should be lazy, stable, support a key function, and optionally treat NaN as equal. Discuss time and space complexity expectations.

2. Design the Generator Structure

Outline a generator function that iterates over the input, computes the key for each element, and checks if the key has been seen. If not, add to seen set and yield the element.

3. Handle Custom Key Function and NaN

Incorporate the key function to transform elements before checking uniqueness. For NaN, detect if the key is NaN (using math.isnan) and replace with a unique sentinel to ensure all NaNs are treated as equal.

4. Analyze Complexity and Trade-offs

Explain that time complexity is O(n) due to single pass, and space is O(k) where k is number of distinct keys. Discuss potential issues with unhashable keys and alternatives like sorting or using a list for small inputs.

5. Test with Edge Cases

Mention testing with empty input, all duplicates, NaNs, custom key functions, and unhashable keys to ensure robustness.

Key Points to Mention

  • Lazy evaluation using generator functions (yield)
  • Stability: preserving original order of first occurrences
  • Custom key function applied before uniqueness check
  • NaN handling: using math.isnan and a sentinel value
  • Time complexity O(n) and space O(k) where k is distinct keys
  • Trade-offs: hashability requirement, memory usage, and alternative approaches for unhashable keys

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