FunctionRacerProblemsRace

First-Time Visitors per Day

EasyHash mapsPython, JavaScript, TypeScript, Java, C++

days[d] lists the names of the people who visited a shop on day d, in the order they came in. A person may come in several times on the same day and on several days.

Return a list with one number per day: how many visits that day were by someone who had never been to the shop before, counting all earlier days and earlier visits of the same day. No days gives [].

Example 1

days [["ann","bob"],["bob","cid","ann"],["dee","dee"]]
returns [2,1,1]

Day 0: ann and bob are new. Day 1: only cid is new. Day 2: dee is new on her first visit, not on her second.

Example 2

days [["x","x","x"]]
returns [1]

The first x is new; the two visits after it are repeats.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Hash maps problems