1141. User Activity for the Past 30 Days I LeetCode Solution

In this guide, you will get 1141. User Activity for the Past 30 Days I LeetCode Solution with the best time and space complexity. The solution to User Activity for the Past Days I problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.

Table of Contents

  1. Problem Statement
  2. Complexity Analysis
  3. User Activity for the Past Days I solution in C++
  4. User Activity for the Past Days I solution in Java
  5. User Activity for the Past Days I solution in Python
  6. Additional Resources
1141. User Activity for the Past 30 Days I LeetCode Solution image

Problem Statement of User Activity for the Past Days I

Table: Activity

+—————+———+
| Column Name | Type |
+—————+———+
| user_id | int |
| session_id | int |
| activity_date | date |
| activity_type | enum |
+—————+———+
This table may have duplicate rows.
The activity_type column is an ENUM (category) of type (‘open_session’, ‘end_session’, ‘scroll_down’, ‘send_message’).
The table shows the user activities for a social media website.
Note that each session belongs to exactly one user.

Write a solution to find the daily active user count for a period of 30 days ending 2019-07-27 inclusively. A user was active on someday if they made at least one activity on that day.
Return the result table in any order.
The result format is in the following example.

Example not found

Constraints not found

Complexity Analysis

  • Time Complexity: Google AdSense
  • Space Complexity: Google Analytics

1141. User Activity for the Past 30 Days I LeetCode Solution in C++

SELECT
  activity_date AS day,
  COUNT(DISTINCT user_id) AS active_users
FROM Activity
WHERE activity_date BETWEEN '2019-06-28' AND  '2019-07-27'
GROUP BY 1;
/* code provided by PROGIEZ */

1141. User Activity for the Past 30 Days I LeetCode Solution in Java

N/A
// code provided by PROGIEZ

1141. User Activity for the Past 30 Days I LeetCode Solution in Python

N/A
# code by PROGIEZ

Additional Resources

Happy Coding! Keep following PROGIEZ for more updates and solutions.