A transit operator instruments every turnstile in its network and streams each tap to a loyalty analytics pipeline. Each tap record names the rider, the calendar date, and whether it was a tap-in (IN) or a tap-out (OUT); only tap-ins matter for this report, and a rider may appear many times across their history. The operator wants a daily "new rider" report: for each date in the 90-day window ending on a given report date (inclusive), how many riders tapped in for the very first time — ever, across their complete history — on that exact date? A rider's first tap-in might have happened long before the window opened, in which case they never appear in the report at all.
today, formatted YYYY-MM-DD.n, the number of tap records.n lines contains a tap record riderId date type, where riderId is an alphanumeric token, date is formatted YYYY-MM-DD, and type is either IN or OUT.Print exactly 90 lines, one for each calendar date from today minus 89 days through today, in ascending chronological order. Each line has the form date count, where count is the number of riders whose earliest-ever IN tap (considering their complete history, not just records inside the window) falls exactly on that date. Dates with no qualifying riders still print count = 0.
riderId consists of 1 to 12 letters and/or digits.today, is a valid calendar date between 2000-01-01 and 2100-12-31.type is exactly IN or OUT.today.IN records.Example 1
Input
2021-01-05 5 alice 2021-01-01 IN bob 2021-01-02 IN alice 2021-01-02 OUT alice 2021-01-03 IN carol 2021-01-05 IN
Expected
2020-10-08 0 2020-10-09 0 2020-10-10 0 2020-10-11 0 2020-10-12 0 2020-10-13 0 2020-10-14 0 2020-10-15 0 2020-10-16 0 2020-10-17 0 2020-10-18 0 2020-10-19 0 2020-10-20 0 2020-10-21 0 2020-10-22 0 2020-10-23 0 2020-10-24 0 2020-10-25 0 2020-10-26 0 2020-10-27 0 2020-10-28 0 2020-10-29 0 2020-10-30 0 2020-10-31 0 2020-11-01 0 2020-11-02 0 2020-11-03 0 2020-11-04 0 2020-11-05 0 2020-11-06 0 2020-11-07 0 2020-11-08 0 2020-11-09 0 2020-11-10 0 2020-11-11 0 2020-11-12 0 2020-11-13 0 2020-11-14 0 2020-11-15 0 2020-11-16 0 2020-11-17 0 2020-11-18 0 2020-11-19 0 2020-11-20 0 2020-11-21 0 2020-11-22 0 2020-11-23 0 2020-11-24 0 2020-11-25 0 2020-11-26 0 2020-11-27 0 2020-11-28 0 2020-11-29 0 2020-11-30 0 2020-12-01 0 2020-12-02 0 2020-12-03 0 2020-12-04 0 2020-12-05 0 2020-12-06 0 2020-12-07 0 2020-12-08 0 2020-12-09 0 2020-12-10 0 2020-12-11 0 2020-12-12 0 2020-12-13 0 2020-12-14 0 2020-12-15 0 2020-12-16 0 2020-12-17 0 2020-12-18 0 2020-12-19 0 2020-12-20 0 2020-12-21 0 2020-12-22 0 2020-12-23 0 2020-12-24 0 2020-12-25 0 2020-12-26 0 2020-12-27 0 2020-12-28 0 2020-12-29 0 2020-12-30 0 2020-12-31 0 2021-01-01 1 2021-01-02 1 2021-01-03 0 2021-01-04 0 2021-01-05 1
Explanation
alice's first-ever tap-in is 2021-01-01 (her later tap-in on 2021-01-03, and her tap-out on 2021-01-02, don't change that). bob's first tap-in is 2021-01-02, and carol's is 2021-01-05. So of the 90 report lines (2020-10-08 through 2021-01-05), every line is 0 except 2021-01-01 -> 1, 2021-01-02 -> 1, and 2021-01-05 -> 1.
Example 2
Input
2019-06-30 3 zeke 2019-01-01 IN yara 2019-04-02 IN xavier 2019-06-30 IN
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →Expected
2019-04-02 1 2019-04-03 0 2019-04-04 0 2019-04-05 0 2019-04-06 0 2019-04-07 0 2019-04-08 0 2019-04-09 0 2019-04-10 0 2019-04-11 0 2019-04-12 0 2019-04-13 0 2019-04-14 0 2019-04-15 0 2019-04-16 0 2019-04-17 0 2019-04-18 0 2019-04-19 0 2019-04-20 0 2019-04-21 0 2019-04-22 0 2019-04-23 0 2019-04-24 0 2019-04-25 0 2019-04-26 0 2019-04-27 0 2019-04-28 0 2019-04-29 0 2019-04-30 0 2019-05-01 0 2019-05-02 0 2019-05-03 0 2019-05-04 0 2019-05-05 0 2019-05-06 0 2019-05-07 0 2019-05-08 0 2019-05-09 0 2019-05-10 0 2019-05-11 0 2019-05-12 0 2019-05-13 0 2019-05-14 0 2019-05-15 0 2019-05-16 0 2019-05-17 0 2019-05-18 0 2019-05-19 0 2019-05-20 0 2019-05-21 0 2019-05-22 0 2019-05-23 0 2019-05-24 0 2019-05-25 0 2019-05-26 0 2019-05-27 0 2019-05-28 0 2019-05-29 0 2019-05-30 0 2019-05-31 0 2019-06-01 0 2019-06-02 0 2019-06-03 0 2019-06-04 0 2019-06-05 0 2019-06-06 0 2019-06-07 0 2019-06-08 0 2019-06-09 0 2019-06-10 0 2019-06-11 0 2019-06-12 0 2019-06-13 0 2019-06-14 0 2019-06-15 0 2019-06-16 0 2019-06-17 0 2019-06-18 0 2019-06-19 0 2019-06-20 0 2019-06-21 0 2019-06-22 0 2019-06-23 0 2019-06-24 0 2019-06-25 0 2019-06-26 0 2019-06-27 0 2019-06-28 0 2019-06-29 0 2019-06-30 1
Explanation
The report window runs from 2019-04-02 through 2019-06-30. zeke's first tap-in (2019-01-01) falls before the window opened, so he never appears in the report at all. yara's first tap-in lands exactly on the window's opening date (2019-04-02 -> 1), and xavier's lands on the report date itself (2019-06-30 -> 1); every other one of the 90 lines prints 0.