← Uber Interview Insights

Uber·Software Engineer·Onsite - Coding / Algorithms·Senior

SeniorPrefer not to say
May 2026

Summary

Three algorithm-heavy coding problems back to back for an Uber SWE round. No behavioral, no system design fluff, just pure data structures the whole time. Left feeling like I either nailed it or completely missed what they were actually testing.

Questions Asked (3)

Q1

Given an integer array and a limit value, find the length of the longest contiguous subarray where the difference between its max and min elements is at most the limit. They wanted a linear time solution.

Algorithms & Data Structures
Author's notes

I knew immediately this was a sliding window problem but the tricky part is maintaining the running max and min efficiently as the window moves.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a sliding window with two monotonic deques to maintain the max and min of the current window in O(1) amortized time. Expand the right pointer, and while the difference between max and min exceeds the limit, shrink from the left. Track the maximum window length throughout.

Pro tip: Emphasize that the monotonic deques store indices, not values, so you can efficiently remove elements that fall out of the window. Also, mention that this approach handles negative numbers and duplicates seamlessly.

1. Clarify and confirm requirements

Restate the problem to ensure understanding: find the longest contiguous subarray where max - min <= limit. Ask about edge cases like empty array, negative numbers, and whether the limit can be negative.

2. Outline the sliding window approach

Explain that you'll maintain a window [left, right] and expand right. Use two deques to track the maximum and minimum values in the current window.

3. Detail the deque operations

For the max deque, before adding a new element, remove indices from the back while the corresponding value is <= the new value. For the min deque, remove while the value is >= the new value. Also, remove indices from the front if they fall out of the window.

4. Shrink window when condition violated

While max - min > limit, increment left. If the front indices of the deques are less than left, pop them. Update the maximum length after each valid window.

5. Analyze complexity and test

State that each element is added and removed from each deque at most once, giving O(n) time and O(n) space. Walk through a small example to verify correctness.

Key Points to Mention

  • Sliding window technique for contiguous subarrays
  • Monotonic deques for O(1) amortized max/min retrieval
  • Time complexity: O(n) because each element is processed at most twice
  • Space complexity: O(n) for the deques in the worst case
  • Handling of edge cases: empty array, limit negative, all elements equal
  • Comparison with alternative approaches like segment trees or heaps (O(n log n))

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

Q2

You have an m by n grid starting as all water. Cells get flipped to land one at a time. After each flip, return both the current number of islands and the size of the largest island.

Algorithms & Data StructuresSystem Design
Author's notes

Classic union-find setup but with the extra twist of tracking max component size.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use Union-Find (Disjoint Set Union) to dynamically track connected components as cells flip to land. For each flip, union the new land cell with adjacent land cells, updating the island count and maintaining the size of the largest island. This approach efficiently handles the incremental nature of the problem with near-constant time per operation.

Pro tip: Mention that Union-Find with union by rank and path compression gives amortized O(α(N)) per operation, and that you can maintain the maximum island size by updating it only when unions occur, avoiding a full scan each time.

1. Clarify requirements and constraints

Confirm grid dimensions, whether flips are given as a list of coordinates, and if multiple flips can occur at the same cell. Ask about expected input size to choose the right algorithm.

2. Choose Union-Find data structure

Explain that Union-Find is ideal for dynamic connectivity. Each land cell is a node; initially all water cells are inactive. When a cell becomes land, it becomes an active node.

3. Process each flip

For each flipped cell, mark it as land, increment island count, and initialize its size to 1. Then check its four neighbors: if a neighbor is land, union the two sets, decrement island count, and update the size of the merged set.

4. Maintain largest island size

Keep a variable for the maximum island size seen so far. After each union, compare the new merged size with the current maximum and update if larger. Also handle the case when a new island of size 1 is created.

5. Return results after each flip

After processing each flip, record the current island count and the maximum island size. Return these as a list of pairs or update a result array.

Key Points to Mention

  • Union-Find with path compression and union by rank/size for near O(1) amortized operations.
  • Mapping 2D grid coordinates to 1D indices for efficient Union-Find implementation.
  • Handling edge cases: flips on already land cells, flips at grid boundaries, and no land cells initially.
  • Maintaining island count by decrementing on each successful union.
  • Tracking maximum island size by updating only when unions occur, not by scanning all islands.
  • Time complexity: O(k α(mn)) where k is number of flips, and space complexity O(mn).

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

Q3

Design an in-memory hit counter that tracks hits over the last 5 minutes, then extend it into a per-user rate limiter with configurable request limits over a rolling time window.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

The hit counter part I've seen before.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (exact vs. rolling window, precision, scale, per-user vs. global) and then propose a simple solution like a circular buffer or timestamp queue for the 5-minute hit counter. For the rate limiter, extend the design to per-user tracking with configurable limits, discussing trade-offs between memory, accuracy, and performance, and consider distributed scenarios if needed.

Pro tip: Mention that a sliding window log can be memory-heavy at scale, so you might use a sliding window counter with approximation or a token bucket for smoother rate limiting, and always discuss how you'd handle distributed rate limiting with Redis or a similar store.

1. Clarify Requirements

Ask about the definition of 'last 5 minutes' (rolling vs. fixed), expected scale (hits per second, number of users), precision requirements, and whether the solution needs to be distributed.

2. Design the Hit Counter

Propose a data structure like a circular buffer of timestamps or a queue with timestamps, and explain how to evict old entries and count hits in O(1) or O(k) time.

3. Extend to Per-User Rate Limiter

Adapt the design to track per-user request timestamps, with configurable limits and window size, and discuss how to enforce the limit (e.g., reject or queue requests).

4. Analyze Trade-offs and Optimizations

Compare approaches (e.g., sliding window log vs. sliding window counter vs. token bucket) in terms of memory, accuracy, and complexity, and suggest optimizations like sharding or approximate counting.

5. Address Distributed and Production Concerns

If relevant, discuss how to scale the solution across multiple servers using a centralized store (e.g., Redis) or a distributed algorithm, and mention concurrency, cleanup, and monitoring.

Key Points to Mention

  • Sliding window vs. fixed window and their impact on accuracy and memory
  • Data structures: circular buffer, queue, timestamp log, or counter with buckets
  • Per-user tracking: using a hash map from user ID to window data
  • Configurable limits: parameters for max requests and window duration
  • Trade-offs: memory vs. precision, and latency vs. accuracy
  • Distributed rate limiting: using Redis, consistent hashing, or local + global limits

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