A 24-hour gaming lounge logs every session played by its members in a check-in ledger. Each entry records a member's id and the calendar date on which they played a session; the same member may appear many times across many dates, in no particular order, and dates may repeat. For every distinct member who appears in the ledger, find their earliest recorded session date — the lounge calls this the member's "kickoff date." Report the kickoff date for every distinct member, ordered by ascending member id.
n, the number of ledger entries.n lines each contain a member id (an integer) and a date in YYYY-MM-DD format, separated by a space.Print one line per distinct member id that appears in the ledger, ordered by ascending member id, each line containing the member id and their earliest recorded date, separated by a single space.
1 <= n <= 10^51 <= member id <= 10^92000-01-01 and 2100-12-31 inclusive, and is a valid calendar date.Example 1
Input
5 1 2016-03-01 1 2016-05-02 2 2017-06-25 3 2016-03-02 3 2018-07-03
Expected
1 2016-03-01 2 2017-06-25 3 2016-03-02
Explanation
Member 1 played on 2016-03-01 and 2016-05-02; the earlier date is 2016-03-01. Member 2 has a single entry, 2017-06-25. Member 3 played on 2016-03-02 and 2018-07-03; the earlier date is 2016-03-02. Sorted by member id, the output lists member 1, then 2, then 3, each with their earliest date.
Example 2
Input
1 5 2020-01-01
Expected
5 2020-01-01
Explanation
There is only one ledger entry, for member 5 on 2020-01-01, so that is trivially their earliest (and only) recorded date.
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 →