Seats

ABC 375

Problem 41 of 50

Easy

What to do

Given a string of seats where '#' = occupied and '.' = empty, count how many times the pattern '#.#' appears — a person in seat i, empty seat i+1, and a person in seat i+2.

Key Concepts

if-statements loops string manipulation counting occurrences

Examples

Input: n = 6, s = '#.##.#'

Output: 2

Input: n = 1, s = '#'

Output: 0

Tips for Beginners

  • Focus on understanding the logic, not memorizing syntax
  • Use print statements to debug your code
  • Don't worry about input parsing - the function handles that for you
  • If stuck, try writing out your solution on paper first

Python Editor

Loading Python...