Tap here to switch tabs
Problem
Submissions

Problem: Maximize Distance to Closest Person

med
30 min
Try to solve the Maximize Distance to Closest Person problem.

Statement

Given a binary array seats representing a row of seats, where seats[i] = 1 means the ithi^{th} seat is occupied and seats[i] = 0 means the ithi^{th} seat is empty, choose an empty seat for Alex such that the distance to the nearest occupied seat is maximized.

Return the maximum possible distance between Alex and the closest occupied seat.

Constraints:

  • 22 \leq seats.length 2×104\leq 2 \times 10^4

  • seats[i] is either 00 or 11

  • At least one seat is empty

  • At least one seat is occupied

Unlock AI-Powered LearningUpgrade to smarter learning with instant explanations of Ask Agent, Personalized Interview Prep, Real-World Projects, 3 AI Mock Interviews per month, and Personalized Paths
Tap here to switch tabs
Problem
Submissions

Problem: Maximize Distance to Closest Person

med
30 min
Try to solve the Maximize Distance to Closest Person problem.

Statement

Given a binary array seats representing a row of seats, where seats[i] = 1 means the ithi^{th} seat is occupied and seats[i] = 0 means the ithi^{th} seat is empty, choose an empty seat for Alex such that the distance to the nearest occupied seat is maximized.

Return the maximum possible distance between Alex and the closest occupied seat.

Constraints:

  • 22 \leq seats.length 2×104\leq 2 \times 10^4

  • seats[i] is either 00 or 11

  • At least one seat is empty

  • At least one seat is occupied

Unlock AI-Powered LearningUpgrade to smarter learning with instant explanations of Ask Agent, Personalized Interview Prep, Real-World Projects, 3 AI Mock Interviews per month, and Personalized Paths