Your question is Trips From License Plate Logs. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
LinkedIn campus parking systems record vehicle events as text logs. Given chronological logs containing license plates and event types, count how many valid parking trips were completed.
Each log line has the format "<license_plate> <event>", where <event> is either ENTRY or EXIT. A trip is counted only when a plate with an active entry later produces an EXIT. After a valid exit, that plate is no longer active and may begin another trip. Ignore unmatched exits and repeated entries while the plate is already active.
Implement count_trips(logs), where logs is a list of strings ordered by event time. Return an integer equal to the number of valid entry-exit pairs. License plates contain non-whitespace characters, and event tokens use uppercase letters.
def count_trips(logs):