FastPrepCinema Seat Allocation
Problems/Cinema Seat Allocation

Cinema Seat Allocation

Zillow logoZillow● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Asked at Zillow in September 2022, in two reports from software engineer intern candidates who each had three interview rounds. In the first report, each of the three rounds had one medium coding problem, along with a lot of behavioral questions, and the problem in the third and last round was about buying cinema tickets; of the three kinds the candidate listed (stack, string, matrix), it is the matrix one. The second report names the problem Cinema Seat Allocation among the questions of its three rounds, without saying which round it came in.

Neither report says what kind of interview the rounds were, so we list it under phone screens, our default when the kind of round is not given.

Neither report spells out the rules. We use the usual rules of the widely known problem with that name: rows of ten seats, aisles after seats 3 and 7, some seats already reserved, and groups of four who sit next to each other, across an aisle only when it splits them two and two. The function gets the number of rows and the reserved seats as [row, seat] pairs and returns the largest number of groups; this input form and the limits (up to 10^9 rows and 10^4 reserved seats) are our choices.

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

A cinema has n rows of seats, numbered from 1 to n. Every row has ten seats, numbered from 1 to 10 from left to right. Two aisles run through every row: one between seats 3 and 4, and one between seats 7 and 8.

Some seats are already reserved. reservedSeats[i] = [row, seat] means that seat number seat in row row is taken.

A group of four people wants four free seats next to each other in one row. Two seats on opposite sides of an aisle do not count as next to each other, with one exception: a group may sit across an aisle when the aisle splits it in the middle, two people on each side.

Return the largest number of four-person groups that can be seated at the same time. No two groups can share a seat.

Function

maxNumberOfFamilies(n: int, reservedSeats: int[][]) → int

Examples

Example 1

n = 3reservedSeats = [[1,4],[1,9],[2,3],[2,8],[3,1],[3,10]]return = 3

In row 1, seats 4 and 9 are taken. Every four seats a group could use in that row include seat 4 or seat 9, so row 1 holds no group.

In row 2, seats 3 and 8 are taken. Seats 4 to 7 are free and lie between the two aisles, so one group sits there.

In row 3, only seats 1 and 10 are taken. One group takes seats 2 to 5, split two and two by the aisle between seats 3 and 4, and another group takes seats 6 to 9, split two and two by the aisle between seats 7 and 8.

That makes 0 + 1 + 2 = 3 groups.

Example 2

n = 4reservedSeats = [[2,5],[4,7]]return = 6

Rows 1 and 3 have no reserved seat, so each holds two groups, one in seats 2 to 5 and one in seats 6 to 9.

In row 2, seat 5 is taken, so the only group that fits uses seats 6 to 9. In row 4, seat 7 is taken, so the only group that fits uses seats 2 to 5.

That makes 2 + 1 + 2 + 1 = 6 groups.

Example 3

n = 1000000000reservedSeats = [[1,5]]return = 1999999999

Row 1 loses seat 5, so it holds one group, in seats 6 to 9. The other 999999999 rows have no reserved seat and hold two groups each, so the answer is 2 * 999999999 + 1 = 1999999999.

Constraints

  • 1 <= n <= 109
  • 1 <= reservedSeats.length <= min(10 * n, 104)
  • reservedSeats[i].length == 2
  • 1 <= reservedSeats[i][0] <= n
  • 1 <= reservedSeats[i][1] <= 10
  • No seat appears twice in reservedSeats.

More Zillow Phone Screen questions

  • Valid ParenthesesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
  • Time Based Key-Value StorePHONE SCREEN · Seen Feb 2024
  • Filter Formatted Records by CriteriaPHONE SCREEN · Seen Sep 2023
  • Build a Hash TablePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2023
  • Jump GamePHONE SCREEN · Seen Dec 2022
  • Reversible Run-Length EncodingPHONE SCREEN · Seen Nov 2022
  • Spiral MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2022
  • Two Sum: All PairsPHONE SCREEN · Seen Nov 2022
  • Employee Free TimePHONE SCREEN · Seen Oct 2022
  • First Unique Character in a StringPHONE SCREEN · Seen Oct 2022

Similar questions at other companies

  • Task Scheduler with CooldownTeradata · PHONE SCREEN
  • Find the Original Array From a Doubled ArrayGoogle · PHONE SCREENGoogle interview questions
  • Future-Aware Cache EvictionBenchling · PHONE SCREENBenchling interview questions
  • Task Scheduler with CooldownSambaNova Systems · PHONE SCREEN · ONSITE INTERVIEWSambaNova Systems interview questions
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Minimum Distinct Prefix CostChubb · OAChubb interview questions
  • Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
  • Rearrange Songs by AuthorZomato / Eternal · OAZomato / Eternal interview questions
  • Nickname-Constrained GroupingZoox · ONSITE INTERVIEW
  • 🐘 Keep Them Apart 🦙QRT · OA
All Zillow interview questionsSee Zillow hiring insights
Saved
class Solution {
    public int maxNumberOfFamilies(int n, int[][] reservedSeats) {
        // Write your code here.
    }
}
Checking account…