CareerVerse's mock-interview scheduler writes one log line every time interview slots are either booked or called off. Each log line records a date, whether it describes "scheduled" or "cancelled" slots, and how many slots that single line represents (one line can represent a batch of several slots created or cancelled together). The same date can appear across several lines, for either category, in any order, and a category may be entirely absent for some date.
For every date that appears at least once in the log, compute diff = (total scheduled slot count on that date) - (total cancelled slot count on that date). If a date never has a line for one of the two categories, treat that category's total as 0 for that date.
Print one line per distinct date that appears in the log, sorted by date ascending. Each line must contain the date, a single space, and the diff value for that date (diff may be negative, zero, or positive).
Example 1
Input
4 2024-01-01 scheduled 5 2024-01-01 cancelled 2 2024-01-02 scheduled 3 2024-01-02 cancelled 3
Expected
2024-01-01 3 2024-01-02 0
Explanation
On 2024-01-01, scheduled total is 5 and cancelled total is 2, so diff = 5 - 2 = 3. On 2024-01-02, scheduled total is 3 and cancelled total is 3, so diff = 0. Dates are printed in ascending order.
Example 2
Input
5 2024-02-10 cancelled 4 2024-02-10 scheduled 1 2024-02-11 cancelled 6 2024-02-09 scheduled 2 2024-02-09 scheduled 3
Expected
2024-02-09 5 2024-02-10 -3 2024-02-11 -6
Explanation
2024-02-09 has only scheduled lines totalling 2+3=5 and no cancelled lines (treated as 0), so diff = 5. 2024-02-10 has scheduled=1, cancelled=4, so diff = -3. 2024-02-11 has only a cancelled line totalling 6 and no scheduled lines (treated as 0), so diff = -6. Output is sorted by date ascending: 02-09, 02-10, 02-11.
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 →