Skip to content

Conversation

@Feminto
Copy link

@Feminto Feminto commented May 29, 2025

No description provided.

@BharathVuppala96
Copy link

Good Work

@super30admin
Copy link
Owner

  1. Correctness:

    • For consecutive_numbers.sql: The solution correctly identifies consecutive numbers using the LEAD window function, which is an appropriate approach for this problem.
    • For num_of_passengers.sql: The solution correctly matches passengers to buses and counts them, handling the case where no passengers are assigned to a bus with IFNULL.
    • For user_activity.sql: The solution correctly counts active users within the last 30 days, filtering by activity_type and date range.
  2. Time Complexity:

    • consecutive_numbers.sql: O(n) where n is the number of rows in logs, due to the window function scan.
    • num_of_passengers.sql: O(n log n) due to the GROUP BY and JOIN operations.
    • user_activity.sql: O(n) for scanning the activity table and applying filters.
  3. Space Complexity:

    • consecutive_numbers.sql: O(n) for storing the intermediate results of the window functions.
    • num_of_passengers.sql: O(n) for the CTE and join results.
    • user_activity.sql: O(n) for storing the filtered results before grouping.
  4. Code Quality:

    • The code is generally well-structured and readable.
    • Consistent use of aliases and indentation.
    • Could improve by adding comments explaining the logic, especially for complex queries like num_of_passengers.sql.
    • In user_activity.sql, the date filter could be more readable using BETWEEN or DATE_ADD instead of two DATEDIFF conditions.
  5. Efficiency:

    • consecutive_numbers.sql: Efficient use of window functions.
    • num_of_passengers.sql: The solution is efficient but could consider indexing arrival_time for better performance on large datasets.
    • user_activity.sql: The query could benefit from an index on activity_date and activity_type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants