FitTrail, a fitness-tracking app, records an entry every time a user logs a workout, but it only stores the date — if a user works out twice on the same day, two entries with that same date can still appear. Product analytics wants an early-retention signal: among all users, what fraction kept training on the very next calendar day after their first-ever logged workout?
You are given every logged entry. For each user, find the earliest date on which they logged a workout — call it their kickoff date. A user counts as retained if any of their entries show a workout on the calendar day immediately following their kickoff date (a later date does not count, only exactly the next day). Compute the fraction of ALL users, retained or not, that are retained, rounded to exactly two decimal places.
Print a single number: the retention fraction, rounded to exactly 2 decimal places (for example 0.50, 1.00, or 0.33), with the trailing zero(s) always shown.
Example 1
Input
3 1 2024-01-01 1 2024-01-02 2 2024-01-05
Expected
0.50
Explanation
User 1's kickoff date is 2024-01-01 and they also have an entry on 2024-01-02 (the very next day), so user 1 is retained. User 2's kickoff date is 2024-01-05 and they have no entry on 2024-01-06, so user 2 is not retained. Retained fraction = 1/2 = 0.50.
Example 2
Input
6 1 2024-03-10 1 2024-03-11 2 2024-03-10 2 2024-03-10 3 2024-05-01 3 2024-05-03
Expected
0.33
Explanation
User 1: kickoff 2024-03-10, has 2024-03-11 -> retained. User 2: kickoff 2024-03-10 (the duplicate entry changes nothing), no 2024-03-11 -> not retained. User 3: kickoff 2024-05-01, has 2024-05-03 but not 2024-05-02 -> not retained (only the immediate next day counts). Retained fraction = 1/3 = 0.33.
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 →