Practice User Activity for the Past 30 Days I
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Tables: Activity(user_id INT, session_id INT, activity_date DATE, activity_type ENUM). Activity permits duplicate rows. activity_type is open_session, end_session, scroll_down or send_message; each session belongs to one user. Return day and active_users for the 30-day interval ending on 2019-07-27 inclusive. Count distinct users with any listed activity per date; repeated events or multiple sessions do not increase that user's daily contribution. Omit dates without activity. Output order is unrestricted.
Source: User Activity for the Past 30 Days I on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Activity table: +---------+------------+---------------+---------------+ | user_id | session_id | activity_date | activity_type | +---------+------------+---------------+---------------+ | 1 | 1 | 2019-07-20 | open_session | | 1 | 1 | 2019-07-20 | scroll_down | | 1 | 1 | 2019-07-20 | end_session | | 2 | 4 | 2019-07-20 | open_session | | 2 | 4 | 2019-07-21 | send_message | | 2 | 4 | 2019-07-21 | end_session | | 3 | 2 | 2019-07-21 | open_session | | 3 | 2 | 2019-07-21 | send_message | | 3 | 2 | 2019-07-21 | end_session | | 4 | 3 | 2019-06-25 | open_session | | 4 | 3 | 2019-06-25 | end_session | +---------+------------+---------------+---------------+
+------------+--------------+ | day | active_users | +------------+--------------+ | 2019-07-20 | 2 | | 2019-07-21 | 2 | +------------+--------------+
Related LeetCode Problems
Practice more problems similar to User Activity for the Past 30 Days I.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.