โ† ่ฟ”ๅ›žๅšๅฎขๅˆ—่กจ
Google

๐Ÿ”ฅ Google VO Real Question: Config Diff System - 3 Followups That Keep Escalating!

2026-01-17

Recently, this Config Diff System question has been frequently appearing in Google VO. What seems like a simple dictionary comparison is actually a progressively challenging engineering design problem.

Many candidates breathe a sigh of relief after finishing the first version, only to be caught off guard by 3 rounds of Followups. Today, oavoservice breaks down this problem completely, from basic to production-level implementation.


๐Ÿ“‹ Problem Description

Given two nested dictionaries left and right, compare them and output a result dictionary with three sections:

  1. added โ€” Keys that exist in right but not in left
  2. deleted โ€” Keys that exist in left but not in right
  3. edited โ€” Keys that exist in both but have different values

๐ŸŽฏ Interview Flow Breakdown

Step 1: Clarify (Critical!)

The interviewer will first ask you to clarify. Make sure to ask:

๐Ÿ’ก oavoservice Tip: The clarification phase determines your first version's complexity. Start simple and leave room for Followups.


โœ… Basic Version: Flat Dictionary Comparison

Approach

Three passes:

  1. Iterate through left keys to find deleted and edited
  2. Iterate through right keys to find added

oavoservice Perfect Solution

def config_diff(left: dict, right: dict) -> dict:
    result = {
        "added": {},
        "deleted": {},
        "edited": {}
    }
    
    # Find deleted and edited
    for key in left:
        if key not in right:
            result["deleted"][key] = left[key]
        elif left[key] != right[key]:
            result["edited"][key] = {"old": left[key], "new": right[key]}
    
    # Find added
    for key in right:
        if key not in left:
            result["added"][key] = right[key]
    
    return result

Example

left = {"a": 1, "b": 2, "c": 3}
right = {"a": 1, "b": 5, "d": 4}

# Output:
{
    "added": {"d": 4},
    "deleted": {"c": 3},
    "edited": {"b": {"old": 2, "new": 5}}
}

Complexity Analysis

Test Case Design

The interviewer will ask how you would design test cases:

  1. Empty dicts โ€” {}, {} โ†’ all empty
  2. Identical โ€” {"a": 1}, {"a": 1} โ†’ all empty
  3. Completely different โ€” {"a": 1}, {"b": 2} โ†’ deleted + added
  4. Only edited โ€” {"a": 1}, {"a": 2}
  5. Mixed cases โ€” added + deleted + edited all present

๐Ÿš€ Followup 1: Support Nested Dictionary

Problem Change

Now values can be nested dictionaries, requiring recursive comparison.

Core Approach

oavoservice Perfect Solution

def config_diff_nested(left: dict, right: dict) -> dict:
    result = {
        "added": {},
        "deleted": {},
        "edited": {}
    }
    
    all_keys = set(left.keys()) | set(right.keys())
    
    for key in all_keys:
        left_val = left.get(key)
        right_val = right.get(key)
        
        if key not in left:
            # Added
            result["added"][key] = right_val
        elif key not in right:
            # Deleted
            result["deleted"][key] = left_val
        elif isinstance(left_val, dict) and isinstance(right_val, dict):
            # Recursively compare nested dicts
            nested_diff = config_diff_nested(left_val, right_val)
            # Only add non-empty results
            if any(nested_diff.values()):
                result["edited"][key] = nested_diff
        elif left_val != right_val:
            # Values differ (including type mismatch)
            result["edited"][key] = {"old": left_val, "new": right_val}
    
    return result

Example

left = {
    "db": {"host": "localhost", "port": 3306},
    "cache": {"enabled": True}
}
right = {
    "db": {"host": "prod.db.com", "port": 3306},
    "cache": {"enabled": True, "ttl": 300}
}

# Output:
{
    "added": {},
    "deleted": {},
    "edited": {
        "db": {
            "added": {},
            "deleted": {},
            "edited": {"host": {"old": "localhost", "new": "prod.db.com"}}
        },
        "cache": {
            "added": {"ttl": 300},
            "deleted": {},
            "edited": {}
        }
    }
}

๐Ÿš€ Followup 2: Support List as Value

Problem Change

Now values can be lists. How do you handle this?

Discussion Points (What the Interviewer Wants to Hear)

The interviewer may not require implementation, but wants to hear your design thinking:

  1. Simple Approach: Whole List Comparison

    • Compare two lists directly with ==
    • If different, mark as edited with old/new
  2. Complex Approach: Element-Level Comparison

    • Need to define what "same element" means
    • If list elements are dicts, may need an ID field for matching
    • Similar to React's key concept
  3. Order Sensitive vs Order Insensitive

    • Are [1, 2, 3] and [3, 2, 1] the same?

oavoservice Recommended Implementation (Whole Comparison)

def config_diff_with_list(left: dict, right: dict) -> dict:
    result = {"added": {}, "deleted": {}, "edited": {}}
    
    all_keys = set(left.keys()) | set(right.keys())
    
    for key in all_keys:
        left_val = left.get(key)
        right_val = right.get(key)
        
        if key not in left:
            result["added"][key] = right_val
        elif key not in right:
            result["deleted"][key] = left_val
        elif isinstance(left_val, dict) and isinstance(right_val, dict):
            nested_diff = config_diff_with_list(left_val, right_val)
            if any(nested_diff.values()):
                result["edited"][key] = nested_diff
        elif isinstance(left_val, list) and isinstance(right_val, list):
            # Whole list comparison
            if left_val != right_val:
                result["edited"][key] = {"old": left_val, "new": right_val}
        elif left_val != right_val:
            result["edited"][key] = {"old": left_val, "new": right_val}
    
    return result

๐Ÿš€ Followup 3: Alternative Output Structure

Problem Change

The interviewer may request a different output format, such as:

Flat Path Format:

{
    "added": ["cache.ttl"],
    "deleted": ["old_key"],
    "edited": ["db.host"]
}

Or Detailed Format with Paths:

[
    {"path": "db.host", "type": "edited", "old": "localhost", "new": "prod.db.com"},
    {"path": "cache.ttl", "type": "added", "value": 300}
]

oavoservice Perfect Solution (Flat Path Version)

def config_diff_flat(left: dict, right: dict, prefix: str = "") -> dict:
    result = {"added": [], "deleted": [], "edited": []}
    
    all_keys = set(left.keys()) | set(right.keys())
    
    for key in all_keys:
        path = f"{prefix}.{key}" if prefix else key
        left_val = left.get(key)
        right_val = right.get(key)
        
        if key not in left:
            result["added"].append(path)
        elif key not in right:
            result["deleted"].append(path)
        elif isinstance(left_val, dict) and isinstance(right_val, dict):
            nested = config_diff_flat(left_val, right_val, path)
            result["added"].extend(nested["added"])
            result["deleted"].extend(nested["deleted"])
            result["edited"].extend(nested["edited"])
        elif left_val != right_val:
            result["edited"].append(path)
    
    return result

๐Ÿ’ก What the Interviewer is Really Testing

This problem tests more than algorithms:

  1. Clarification Skills โ€” Ask before you code
  2. Recursive Thinking โ€” Handling nested structures
  3. Edge Cases โ€” Type mismatches, null handling
  4. Engineering Mindset โ€” Output format design, extensibility
  5. Trade-off Discussion โ€” Multiple approaches for List comparison

๐Ÿคฏ Common Pitfalls


๐Ÿš€ oavoservice: Your Google VO Full Support

Google interviews are characterized by layered Followups โ€” one problem can be explored for 30-45 minutes. Many candidates do well on the basic version but get stumped during Followups.

oavoservice's Real-time VO Assistance helps you:

โœ… Real-time strategy hints โ€” Anticipate Followup directions

โœ… Edge case reminders โ€” Don't miss critical cases

โœ… Discussion point preparation โ€” Trade-off analysis support

โœ… Non-intrusive โ€” Compatible with Google Meet / Zoom

Don't let a Followup cost you your Google offer.

We consistently provide professional interview assistance services for major tech companies like Google, Meta, Amazon, and TikTok. Feel free to contact us if you're interested.

๐Ÿ‘‰ Add WeChat now: Coding0201

Secure your Google interview opportunity!