Fewest Two-Seat Pool Cars for Riders Under a Luggage Limit

Last updated: November 29, 2026

Quick Overview

Each rider has a luggage weight and each pool car can carry at most two riders with total luggage at most L; given all weights (each at most L), return the minimum number of cars needed.

Uber
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Each rider has a luggage weight and each pool car can carry at most two riders with total luggage at most L; given all weights (each at most L), return the minimum number of cars needed.

UberX Share and pooled products constantly trade off matching quality against capacity. This screen question checks that you can find and justify the greedy pairing, then implement it with sorting and two pointers.

What the Interviewer Expects
  • Sort the weights
  • Pair the heaviest rider with the lightest when possible
  • Prove the greedy choice by an exchange argument
  • Implement in O(n log n)
  • Handle odd counts and riders who must ride alone
Key Topics to Cover
greedy
two pointers
sorting
exchange argument
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What if a car can carry up to three riders?
  • What if riders also have pickup locations and pairs must be within 2 km?
  • How would you return the actual pairings?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: list weights with each w <= L, integer L.
  • Each car holds one or two riders; total weight must be <= L.
  • Output: minimum number of cars....
High-Level Design

Sort ascending and keep i at the lightest and j at the heaviest unassigned rider. The heaviest rider needs a car either way. If the lightest rider fits with them, pairing them is never worse: in a...


Submit Your Answer
Markdown supported