FastPrepBusiest Station on a Grid
Problems/Busiest Station on a Grid

Busiest Station on a Grid

DocuSign logoDocuSign● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report from December 2019 lists this as the first of three onsite sessions. Stations sit on a grid, each spot is served by the closest station, and the question is which station serves the most spots. The candidate solved it by counting.

The report does not say how distance is measured, how ties break, or what the limits are, and it gives no examples. Here distance counts up, down, left and right steps (|x1 - x2| + |y1 - y2|). A cell that is equally near several stations goes to the smallest index. A tie for the most cells also goes to the smallest index. You return that index. The grid is at most 100 by 100 with up to 100 stations. We wrote the examples.

Our version is about 80% the same as the reported question.

A city is a grid of width by height cells. A cell is written (x, y), where 0 <= x < width and 0 <= y < height. You are given stations, where stations[i] = [x, y] is the cell of station i.

Every cell of the grid, including the cells that hold stations, uses its nearest station. The distance between cells (x1, y1) and (x2, y2) is |x1 - x2| + |y1 - y2|, the number of steps when you can only move up, down, left or right. If a cell is equally near to several stations, it uses the one with the smallest index.

Return the index of the busiest station: the station used by the most cells. If several stations are used by the same, largest number of cells, return the smallest of their indexes.

Function

busiestStation(width: int, height: int, stations: int[][]) → int

Examples

Example 1

width = 4height = 3stations = [[1,1],[3,2]]return = 0

Write each cell's station number, one row per y. Row y = 0: 0 0 0 1. Row y = 1: 0 0 0 1. Row y = 2: 0 0 1 1. Station 0 serves 8 cells and station 1 serves 4, so the answer is 0.

Example 2

width = 5height = 3stations = [[4,1],[0,1]]return = 0

The stations sit at the two ends of the middle row. Each cell in column x = 2 is equally far from both stations (2 steps in the middle row, 3 in the top and bottom rows), so they go to the smaller index, station 0. Station 0 serves columns 2, 3 and 4 (9 cells) and station 1 serves columns 0 and 1 (6 cells). The answer is 0.

Example 3

width = 5height = 2stations = [[0,0],[4,1]]return = 0

Row y = 0: 0 0 0 1 1. Row y = 1: 0 0 1 1 1. No cell is a tie, and each station serves 5 cells. When stations tie for the most cells, return the smallest index, so the answer is 0.

Constraints

  • 1 <= width, height <= 100
  • 1 <= stations.length <= 100
  • stations[i].length == 2
  • 0 <= stations[i][0] < width and 0 <= stations[i][1] < height
  • No two stations are on the same cell

More DocuSign Onsite Interview questions

  • Count Binary SubstringsONSITE INTERVIEW · Seen Sep 2026
  • Two Positions That Add Up to a TargetPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Compress Consecutive Integer RangesONSITE INTERVIEW · Seen Aug 2026
  • JSON Schema Object ValidatorONSITE INTERVIEW · Seen Aug 2026
  • Most Transactions Kept Without Going NegativeONSITE INTERVIEW · Seen May 2025
  • Three-Part Splits With a Light MiddleONSITE INTERVIEW · Seen May 2025
  • Combine Two Sorted Lists Into OneONSITE INTERVIEW · Seen Apr 2022
  • Exact Palindrome CheckPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
  • Paired Words That Share a SubstringONSITE INTERVIEW · Seen Apr 2022
  • Reverse the Characters of a TextPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022

Similar questions at other companies

  • Rotting OrangesSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Minimum Time to Spread Through a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Minimum Time to Rot All OrangesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Number of Islands with Diagonal ConnectivityGoogle · ONSITE INTERVIEWGoogle interview questions
  • Island Count and Maximum AreaOracle · ONSITE INTERVIEWOracle interview questions
  • Shortest Increasing Path to a TargetUber · ONSITE INTERVIEWUber interview questions
  • Find and Reconstruct a Binary-Matrix PathMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Rotting OrangesOtter.ai · ONSITE INTERVIEWOtter.ai interview questions
  • Fuel-Aware Grid ReachabilityBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Maximum Number of Fish in a GridGlobalization Partners · ONSITE INTERVIEW

Interview reports that mention this question

  • DocuSign SWE Intern Interviews: 27 Experiences (Part 2 of 2)

DocuSign interview experiences

  • DocuSign SWE Intern OA Questions: 53 Experiences (Part 1 of 2)
All DocuSign interview questionsSee DocuSign hiring insights
Saved
class Solution {
    public int busiestStation(int width, int height, int[][] stations) {
        // Write your code here.
    }
}
Checking account…