Uber - SDE 2 - March 2025 [Offer]

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-07-14Added By Anonymous
Source: Link

Company: Uber
Role: Software Development Engineer II
Interview Stage: Onsite
Location: unknown
Year: 2025

Original Post Content:

Uber — Backend Engineer (SDE 2) Interview Experience
Month / Year : March 2025
Position : Software Development Engineer II (Backend)
Track : Data-Structures & Algorithms (DSA) + Low-Level Design (LLD) + High-Level Design (HLD) + Bar Raiser

# Source
A senior talent-partner at Uber reached out to me on LinkedIn. We spoke for 10 minutes about the role and expectations, and I was directly scheduled for first round of interview over the next few days. There were 5 rounds in total and each one is supposed to be an elimination round.

# Round 1 – DSA (60 min)

Topic: Q1 – Real-time Fraud-Check on Card Transactions
Details: *Problem statement* (white-board+IDE): Detect whether any incoming card transaction is fraudulent by checking if, within the previous k events (k ≤ 3 by default, but configurable), there exists a complementary credit + debit pattern summing to zero for the same account.
• Discussed naïve *O(k²)* pair scan, then jumped to an optimal sliding-window + unordered_set for *O(k)* per event.
• Explained memory trade-off for billions of daily events and why a fixed-size ring-buffer + Bloom filter works better for cache-locality.
Follow-ups: ① Extend to *k = variable* at runtime
② What if events arrive out of order?
③ How would you batch-process in Kafka?
④ Very brief design of API rate-limiter (token-bucket vs. leaky-bucket) for the fraud-check endpoint.
Complexity: *Time* – O(1) amortised per event. *Space* – O(k).
Outcome: Implemented the optimal code in C++ immediately, added handling for edge-cases (duplicate timestamps, negative amounts). Interviewer said: “That’s exactly what I wanted to see.” A Green flag in my opinion.

# Round 2 - DSA (60 min)

Item: Problem – Determine the Alien Alphabet Order
Details: Given a dictionary of words already sorted in an unknown (alien) language, return a valid ordering of its characters.
Interviewer’s format requirements:
1) Start with plain-English intuition.
2) List viable data-structures and trade-offs.
3) Describe the approach & algorithm step-by-step.
4) Analyse time/space complexity and edge-cases.
5) Write production-quality C++
My flow (condensed):
Intuition – the first mismatching character between adjacent words gives a precedence edge; topologically sort those edges.

Data structures – adjacency-list (`unordered_map<char,vector<char>>`) + in-degree map; Kahn’s BFS vs DFS, chose <strong>Kahn</strong> for clearer cycle detection.<br /><br /> <strong>Algorithm</strong> –<br /> 1. Collect all unique chars.<br /> 2. For each consecutive pair, find first mismatch → add edge A→B.<br /> 3. Compute in-degrees.<br /> 4. Run Kahn’s topo-sort to build order.<br /> 5. Detect prefix conflicts (e.g. “abc” before “ab”).<br /><br /> <strong>Edge cases handled</strong> – empty list, single word, cycles, prefix conflict.<br /><br /> <strong>Complexities</strong> – O(N × M) time (N words, avg. length M), O(V+E) space.<br /><br /> <strong>Code</strong> – delivered a fully-commented C++14 solution (≈ 90 LOC), compiled in the shared IDE, and walked through a dry-run on<br /> `["xww","wxyz","wxyw","ywx","ywz"] → order "xzwy"`.<br /><br /> <strong>Follow-ups</strong> – multiple valid orders; swapping to DFS; handling ≥ 26-char alphabet; streaming input.<br /> <strong>Outcome:</strong> Interviewer said the structure and clarity looks fine. A green flag.

# Round 3 – LLD (60 min)

Topic: Q – Random Tambola / Bingo Ticket Generator
Details (expanded with deeper intuition & design rationale):
▪ Problem framing & intuition
▪ A UK-style ticket is a 3 × 9 grid that must satisfy eight hard constraints: ① exactly 5 numbers in every row (15 numbers total); ② every column range is exclusive (1-10, 11-20, …, 81-90), so left-to-right order is naturally ascending; ③ a column contains 1 – 3 numbers (≤ 3 because there are only 3 rows, ≥ 1 so no empty column); ④ numbers within a column must be top-to-bottom ascending; ⑤ rows must remain non-overlapping and strictly increasing left→right; ⑥ two tickets produced consecutively must differ (true randomness); ⑦ solution must be deterministic-free but re-entrant & testable; ⑧ generator must finish well under 50 ms so it can be called synchronously from a game server.
▪ The core insight is that choosing *where* numbers land (boolean matrix) is combinatorial but tiny (27 cells) – once that’s fixed, filling actual values is trivial because column ranges do the heavy lifting.
My Approach (design deep-dive):
1. Domain model
`Ticket (value object)` → holds a `Cell[3][9]`;
`Cell` (has row, col, value);
`TicketGenerator` (service) orchestrates the algorithm;
`NumberPool` (utility) lazily produces shuffled ranges per column;
`TicketBuilder` (Builder pattern) hides the incremental steps so new rules (e.g., themed cards) plug in without polluting the generator.

2. Algorithmic strategy
① Use a recursive backtracking DFS to pick 5 columns per row, guarded by `colUsage[c] ≤ 3`.
② After the third row, verify every `colUsage[c] ≥ 1` (guarantees “at least one per column”).
③ For each column, pull *k* distinct numbers from its 10-number bucket, sort them, then assign them to the occupied rows in row-index order → satisfies column ascending.
④ Wrap the DFS in a retry loop with a max-attempt threshold (heuristic cut-off) to avoid theoretical starvation; practically succeeds in < 1 ms.

3. Patterns & trade-offs
*Builder* → keeps construction fluent and immutable once built.

Why backtracking vs. math / bit-mask generation? Backtracking is easier to reason about, guarantees completeness, and the state-space (126³ ≈ 2 M) is tiny.

5. Extensibility hooks
• `Validator` SPI to plug extra business rules.
• Optional persistence layer (`BingoCard`, `BingoCell` tables; 1→N) if we ever need historical replays.
Code (demo): Delivered ~160 LoC production-style Java 17: interface-first, package `com.uber.bingo` & log markers (`SLF4J`). Wrote few Junit Tests that proved : (a) 15 numbers, (b) 1–3 per column, (c) ascending column order, (d) uniqueness across 1 K consecutive generations.
Edge-cases handled: • Column starvation → early back-track.
• Duplicate numbers in a column → avoided by set-based sampling.
• Deterministic test mode via injected seed.
• Heavy load → generator is CPU-only, no I/O, so horizontally scalable.
Outcome: Interviewer probed “What if the DFS never finishes?” → I explained to put a hard upper limit on how many different column-layouts the backtracking DFS is allowed to explore before we give up. If the DFS hits that cap, we return a pre-validated ticket from a cache of templates, picking it uniformly at random with reservoir sampling so no template is favoured over another. Interviewer seemed satisfied. A green flag.

# Round 4 – HLD (60 min)

Section: Problem statement (clarified in first 5 min)
What I did in the interview: “Design an e-commerce browsing subsystem that surfaces merchandise lists and highlights ‘top items’ ranked by popularity.” I confirmed scope: read-heavy, write-light, no checkout flow, latency ≤ 150 ms P95, 99.95 % availability, global users, popularity freshness ≤ 5 min, eventual consistency OK.
Section: Intuition
What I did in the interview: Treat browsing as *two orthogonal concerns*:
1️⃣ Search/filter → solved with an inverted index (Elasticsearch/Solr).
2️⃣ Popularity ranking → maintain a near-real-time Popularity Cache keyed by `itemId → score`. Combine the two at query time so we never rebuild search indices for each score bump.
Section: High-level architecture
What I did in the interview: Client → API Gateway / LB → Browse-Service
• Browse-Service fan-outs to:
– Search-Service (Elasticsearch) for candidate item IDs & faceted filters.
– Popularity-Cache (Redis/Memcached) for the latest scores.
• It stitches, sorts, paginates, and returns DTOs.

Write path (events) → Kafka → Popularity Aggregator (Flink job)
• Aggregator increments counters, periodically writes top-N lists and per-item scores back to Redis (and S3 for offline analytics).
Section: Key components & tech choices
What I did in the interview: *Catalog DB* → MySQL with range-sharding on `itemId` (ACID for product updates).
*Search* → Elasticsearch 8.x cluster with daily incremental index; popularity kept out-of-band.
*Popularity Aggregator* → Apache Flink (windowed aggregations) for ≤ 5 min staleness.
*Cache* → Redis Cluster (slot-sharded) with 3-day TTL,
*CDN* → CloudFront for static assets
Section: Read flow (happy path)
What I did in the interview: 1. Client calls `/browse?cat=shoes&sort=pop`.
2. Browse-Svc hits ES → returns 1 000 candidate IDs.
3. Bulk `MGET` to Redis for scores (fallback = 0).
4. In-memory sort, apply pagination, fetch missing item metadata from *Catalog Read Replica*.
5. Respond in ~80 ms.
Section: Write flow (popularity)
What I did in the interview: ① Client view/click → Event SDK pushes JSON to Kafka `item_interactions`.
② Flink job computes sliding-window counts (e.g., 1 h decay) → score = α·clicks + β·views.
③ Job writes `HSET popularity:{itemId} score {value}` and updates per-category top-N sorted sets.
④ Browse-Svc subscribes to invalidation channel to refresh local LRU.
Section: Trade-offs discussed
What I did in the interview: *Why ES + Redis vs. scoring directly in ES?* → Avoids costly re-indexing; Redis gives sub-millisecond score look-ups.
*Eventual vs. strong consistency*: popularity may lag < 5 min; acceptable for discovery use-case. Strong consistency would triple infra cost.
Section: Edge-case handling
What I did in the interview: • Cold-start (new items) → bootstrap with Bayesian prior or “new-arrival” bucket to avoid zero-score starvation.
•Ranking abuse (bot traffic) → Rate-limit event SDK, anomaly detection job on Flink.
Section: Scalability notes
What I did in the interview: • Horizontal scale on Browse-Svc (stateless, behind LB).
• Kafka topic = 4× peak partitions (rule-of-thumb) → 2× future headroom.
Section: Interview outcome
What I did in the interview: Sketched sequence diagram & component diagram on Miro, walked through failure scenarios (Redis node loss, ES hot shard). Interviewer seemed satisfied.

# Round 4 – Bar-Raiser (60 min)

Theme: Project deep-dive
What happened: The interviewer asked me to “pick the most complex feature you owned end-to-end.”
My examples & reflections: Answered from my experience.
Theme: On-call & P1 incident handling
What happened: “Describe a recent Sev-1 you owned from pager to post-mortem.”
My examples & reflections: I narrated a Redis cluster mis-config incident:
1️⃣ Opsgenie alert (p95 latency > 900 ms).
2️⃣ First 5 min: traffic shed via Envoy circuit breaker; switched reads to read-replicas.
3️⃣ 10 min: rolled back feature flag that amplified cache churn.
4️⃣ 20 min: added a 2-layer LRU in-process cache as stop-gap.
5️⃣ 24 h: RCA doc, action items (redis-cluster config guardrail, ).
Theme: Behavioural probes
What happened: *Bias for Action* – “Tell me a time you shipped with <10 % specs.”
*Dive Deep* – “How do you decide when to refactor vs. rewrite?”
*Disagree & Commit* – “A staff engineer vetoes your design—what next?”
My examples & reflections: I shared : One of my 0-1 feature I worked on. Would be unfair to share it here.
Theme: Moment I stumbled
What happened: When asked, “What exact SLO did you enforce on one of my features?” I initially quoted *p99 < 2 s*—they pushed for the rationale.
My examples & reflections: I hesitated (“Umm, because that’s what product wanted…”)
Theme: Interviewer’s closing note
What happened: He appreciated the concrete incident steps and the metric-driven design recount, but advised “anchor every number you give with the ‘why’.” Overall feedback felt positive, though I sensed they were fishing for crisp Amazon-style LP answers.
My examples & reflections:

Take-away for future bar-raiser rounds
• Lead with why behind every latency / availability target.
• Keep one battle-tested P1 narrative memorised (timeline + metrics).
• If you sense they want a framework (e.g., run-book steps), articulate it first, then layer your story.

Verdict

Got a call few days later. I was selected.
Although I rejected, because I was not satisfied with the compensation. Felt it was low balled.

Comments