Skip to content
← Back to the archive

5 September 2026

Regular Routes

Medium Dictionaries

Return the bus routes that appear exactly twice.

You are given bus route names in the order they were seen. Count how many times each route appears. Return the route names that appear exactly twice, keeping the order in which those routes first appeared. Return an empty list when no route appears exactly twice.

Constraints

  • routes contains at most 100 lowercase route names
  • A route name may appear any number of times
  • Return each qualifying route only once

Function signature

def regular_routes(routes):

Sign in to solve this bracket

Reading the problem is free for everyone. Opening the editor and solving it requires an account with Open Bracket+.