FastPrepMaximize Compatible Car Riders
Problems/Maximize Compatible Car Riders

Maximize Compatible Car Riders

Uber Freight logoUber Freight● MediumFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives the compatibility rule, an example, and an expected linear-time solution. It leaves the choice of a subset and the empty result unstated. Our version is about 96% the same as the reported question.

There are n riders. Rider i is willing to share a car only when the number of other selected riders is between minCoRiders[i] and maxCoRiders[i], inclusive.

You may select any subset of riders. Return the maximum possible number of selected riders such that every selected rider accepts the resulting group size. Return 0 when no non-empty compatible group exists.

For a group of size k, a rider is eligible exactly when minCoRiders[i] <= k - 1 <= maxCoRiders[i].

Function

maximumCompatibleRiders(minCoRiders: int[], maxCoRiders: int[]) → int

Examples

Example 1

minCoRiders = [0,1,1,2,2]maxCoRiders = [1,2,2,4,4]return = 3

A compatible group of three can be chosen, while fewer than four riders accept having three co-riders.

Example 2

minCoRiders = [0,0,0]maxCoRiders = [0,2,2]return = 2

Two riders accept one co-rider each; a group of three has only two eligible riders.

Constraints

  • 1 <= minCoRiders.length <= 200000
  • maxCoRiders.length == minCoRiders.length
  • 0 <= minCoRiders[i] <= maxCoRiders[i] < n

Similar questions at other companies

  • Call Auction Clearing Price and Order FillsHudson River Trading · PHONE SCREENHudson River Trading interview questions
  • Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
  • Optimal TransferSnowflake · OASnowflake interview questions
  • Minimum Redistribution CostAmazon · OA
  • Gas Station Loop StartNutanix · OANutanix interview questions
  • Redistribute MegaseedsRubrik · OARubrik interview questions
  • Maximum Distinct Items Within a BudgetAdobe · OAAdobe interview questions
  • Minimum AmountBelvedere Trading · OA
  • Focus on Efficiency (2024 NG)Google · OAGoogle interview questions
  • Running Through Walls with Limited EnergyScale AI · OAScale AI interview questions
All Uber Freight interview questionsSee Uber Freight hiring insights
Saved
class Solution {
    public int maximumCompatibleRiders(int[] minCoRiders, int[] maxCoRiders) {
        // Write your code here.
    }
}
Checking account…