Problem 110951 · easy · Phase 01 Prerequisites & Setup

First Free Seat

nested loops · strings · lists

A cinema seating plan is a list of strings, one per row, where X is a taken seat and . is a free seat. Return [row, col] of the first free seat when scanning rows from top to bottom and, inside each row, seats from left to right. If no seat is free return [-1, -1].

Examples

Input:  plan = ["XXX", "X.X"]
Output: [1, 1]

Input:  plan = ["XX"]
Output: [-1, -1]

Constraints

  • 0 <= len(plan) <= 60, every row has the same length between 0 and 60.

Goals

  • Scan a grid of strings row by row, column by column
  • Return early from inside nested loops
Starting Python…