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 namesA route name may appear any number of timesReturn each qualifying route only once
Function signature
def regular_routes(routes):