FastPrepFarthest Seat Assignment
Problems/Farthest Seat Assignment

Farthest Seat Assignment

Uber logoUber● MediumFULLTIMEONSITE INTERVIEW

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Design the assignment behavior for a row of n seats numbered from 0 to n - 1. Each call assigns one unoccupied seat to a new employee. The chosen seat must maximize the distance to the nearest occupied seat. If multiple seats have the same best distance, choose the smallest seat index.

Return the first count assigned seats. If count is larger than n, return only the n actual assignments.

Function

assignSeats(n: int, count: int) → int[]

Examples

Example 1

n = 10count = 5return = [0,9,4,2,6]

The first two assignments take the ends. The third assignment chooses seat 4, which is one of the middle seats farthest from 0 and 9; ties use the smaller index.

Example 2

n = 3count = 4return = [0,2,1]

Only three seats exist, so only three assignments are returned.

Constraints

  • When no seats are occupied yet, assign seat 0.

More Uber Onsite Interview questions

  • Random Bingo Card GeneratorONSITE INTERVIEW · Seen Dec 2026
  • Travelers per Consecutive City TripletONSITE INTERVIEW · Seen Dec 2026
  • Earliest Time All Users Are ConnectedPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Online Meeting Scheduler with Fixed RoomsONSITE INTERVIEW · Seen Oct 2026
  • Minimum Meeting Rooms with AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Serialize and Deserialize an N-Ary TreeONSITE INTERVIEW · Seen Oct 2026
  • Longest Continuous Subarray Within an Absolute-Difference LimitONSITE INTERVIEW · Seen Oct 2026
  • K Smallest Squares from a Sorted ArrayONSITE INTERVIEW · Seen Sep 2026
  • Grid Robot Route with Charging PrioritiesPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Shortest Increasing Path to a TargetONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Priority Ad Rotation with Show LimitsAmazon · ONSITE INTERVIEW
  • Design Authentication ManagerOracle · ONSITE INTERVIEWOracle interview questions
  • Lowest-Bid Auction SystemGoogle · ONSITE INTERVIEWGoogle interview questions
  • Top K Largest Values from a StreamThe D.E. Shaw Group · ONSITE INTERVIEWThe D.E. Shaw Group interview questions
  • Delayed Job SchedulerWalmart Labs · ONSITE INTERVIEW
  • Mutable Stock Price Top KBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Thread-Safe Task Storage and Worker DispatchNuro · ONSITE INTERVIEWNuro interview questions
  • Notification Deduplication WindowGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Fixed-K Kth Largest StreamAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Helpdesk Ticket ProcessingThe Walt Disney Company · ONSITE INTERVIEWThe Walt Disney Company interview questions
All Uber interview questionsSee Uber hiring insights
Saved
class Solution {
    public int[] assignSeats(int n, int count) {
        // write your code here
    }

}
Checking account…