Skip to content

Conversation

@avishwak
Copy link

@avishwak avishwak commented Jun 2, 2025

submitted by Akanksha Vishwakarma_RN31MAY2025DS

@super30admin
Copy link
Owner

FEEDBACK: The student has not provided any solution to the problem. For a medium difficulty SQL problem, I would expect to see at least a basic query structure addressing the problem requirements. Without seeing any code, I cannot evaluate correctness, complexity, or quality. I recommend the student attempt to solve the problem and submit their solution for review. Some general advice for SQL problems: start by understanding the database schema and requirements clearly, write simple queries first and then build up complexity as needed, and always test queries with different edge cases.

@super30admin
Copy link
Owner

  1. Correctness:

    • For Game Play Analysis II (01-GamePlayAnalysis-II.sql), the solution correctly identifies the first login device for each player by using MIN(event_date) and grouping by player_id. However, the query could be more precise by explicitly selecting the device_id associated with the minimum event_date.
    • For Game Play Analysis III (02-GamePlayAnalysis-III.sql), both the window function and subquery approaches correctly calculate the running total of games played. The window function approach is more efficient.
    • For Combine Two Tables (04-CombineTwoTables.sql), the solution correctly performs a LEFT JOIN to include all persons even if they don't have an address.
  2. Time Complexity:

    • Game Play Analysis II: O(n) for the GROUP BY operation.
    • Game Play Analysis III: The window function approach is O(n log n) due to the PARTITION BY and ORDER BY. The subquery approach is O(n^2) as noted by the student.
    • Combine Two Tables: O(n) for the JOIN operation.
  3. Space Complexity:

    • All solutions have O(n) space complexity as they process and return a result set proportional to the input size.
  4. Code Quality:

    • The code is generally readable and well-structured.
    • Comments are helpful, especially in explaining why certain approaches are less efficient.
    • For Game Play Analysis II, the query could be improved by using a more explicit approach like:
      SELECT player_id, device_id 
      FROM Activity 
      WHERE (player_id, event_date) IN (
          SELECT player_id, MIN(event_date) 
          FROM Activity 
          GROUP BY player_id
      )
  5. Efficiency:

    • The student correctly identifies the inefficiency of the subquery approach in Game Play Analysis III and prefers the window function approach, which is good.
    • The solution for Game Play Analysis II could be optimized as mentioned above to ensure it correctly handles cases where multiple devices might have the same minimum event_date.

Copy link
Author

@avishwak avishwak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added solution to two more problems i.e 3 and 5

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