Uber | passed | dec 2024 | L4 | Bangalore

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2024-12-11Added By Anonymous
Source: Link

Company: Uber
Role: L4
Interview Stage: Onsite
Location: Bangalore
Year: 2024

Original Post Content:

---

Years of Experience: 4 years

---

📋 Screening Round (DSA)

You are given a 2D grid of integers with n rows and m columns.
You are also given two integers h and w — the height and width of a sliding window.

Your task is to slide an h × w window over the grid, from top-left to bottom-right, and for each such window, count the number of inversions in the flattened subgrid.

An inversion is a pair of elements (a, b) such that:

  • a appears before b in row-wise order (left to right, then top to bottom),
  • and a > b.

Window Sliding Rules:

  • You must slide the window one column at a time to the right, until it fits within the row.
  • Then move down one row and continue sliding from the left.
  • Only windows fully contained within the grid should be considered.
  • There are exactly (n - h + 1) × (m - w + 1) valid top-left corners for the sliding window.

I said, bruteforce, interviewer simply denied and asked for optimization, after thinking for like 20 minutes, I came up with a solution and solved it in
O(Q * sqrt(N*M) * log N) for Q = (n−h+1) × (m−w+1)

interviewer was expecting better complexity but I passed this round.

---

Round 1: DSA + Problem Solving

Problem Statement:
You're given a shuffled array containing all integers from 1 to n exactly once. You must sort it in the minimum number of passes, where in each pass, you can collect a strictly increasing subsequence from left to right.

  • Proposed and implemented a greedy approach using a pointer and visited flags.
  • Discussed: Time and space complexities Edge cases like reverse-sorted input Possible DP optimizations and a follow-up variant involving duplicates
  • The follow-up was brainstormed, not coded.

---

🔸 Round 2: LLD (Low-Level Design)

Design Question: Implement a simplified Randomized Set data structure

  • Functional Requirements: Insert, delete, search — all in average constant time Should support random element access Should handle duplicates if required
  • Proposed a hybrid structure using: HashMap (for O(1) lookups) Array/List (for O(1) random access)
  • Implemented insert and getRandom
  • Covered: Tradeoffs between space and time Handling edge cases (like deleting the last element) Testing strategy for random behavior

---

🔹 Round 3: HLD (High-Level Design)

System Design Question:
Design a globally distributed, real-time travel query suggestion system that supports geo-aware filtering, typo-tolerant fuzzy matching, multilingual queries, real-time trending detection, and personalized re-ranking—all at sub-100ms latency while serving billions of queries daily across regions.

---

Comments