← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Uber SWE interview with a recursive equality problem. Nothing flashy, just a clean algorithmic question that required careful handling of type semantics and nested structures.

Questions Asked (1)

Q1

Given two JSON-like records that can contain scalars, lists, and nested objects, write a function to determine if they are deeply equal. Scalar equality must be type-strict (so 1 and "1" are not equal), list equality is order-sensitive, and object equality ignores key order.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Recursion was the obvious move and I got there quickly, but I fumbled the scalar type-checking part at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem and edge cases, then outline a recursive solution that handles each type (scalar, list, object) with appropriate equality checks. Emphasize type-strict scalar comparison, order-sensitive list comparison, and key-order-independent object comparison. Discuss complexity and potential optimizations like early termination.

Pro tip: Mention that you would handle circular references gracefully, either by detecting cycles or assuming they don't exist based on the problem constraints. Also, discuss the trade-off between recursive and iterative approaches, especially for deeply nested structures.

1. Clarify requirements and edge cases

Ask about the definition of 'JSON-like', handling of null, undefined, special numeric values (NaN, Infinity), and circular references. Confirm that type-strict equality means no type coercion.

2. Design recursive algorithm

Outline a function that first checks if both inputs are of the same type. For scalars, compare directly; for lists, compare length and each element recursively; for objects, compare key sets and then values recursively.

3. Implement with early termination

Write pseudocode or actual code, ensuring that comparisons short-circuit on first mismatch. Use helper functions for type checking and recursion.

4. Analyze complexity and trade-offs

Discuss time complexity O(n) where n is total number of elements, and space complexity O(d) for recursion depth. Mention iterative alternatives using stacks to avoid stack overflow.

5. Test with examples

Walk through test cases: equal scalars, different types, lists with same elements in different order, objects with same keys in different order, nested structures, and edge cases like empty lists/objects.

Key Points to Mention

  • Type-strict scalar equality (e.g., 1 !== '1', true !== 1)
  • Order-sensitive list comparison (compare element by element)
  • Key-order-independent object comparison (compare key sets and values)
  • Recursive approach with base cases for scalars, lists, and objects
  • Handling of edge cases: null, undefined, NaN, circular references
  • Time and space complexity analysis, and potential iterative optimization

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