An activity feed groups events under date headers. Each event's time is a string like "2024-03-02 09:15" (year, month, day, then hours and minutes).
Write eventsPerDay(timestamps) that returns one [day, count] pair per day that has events, where day is the "YYYY-MM-DD" part. Sort the pairs by day, earliest first.
Input: timestamps = ["2024-03-02 09:15","2024-03-01 18:00","2024-03-02 23:59"] Output: [["2024-03-01",1],["2024-03-02",2]]
Two events fall on March 2 and one on March 1, and March 1 comes first.
Input: timestamps = [] Output: []
No events, no days.
0 <= timestamps.length <= 10^5"YYYY-MM-DD HH:MM".Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #34 Events per Calendar Day. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.