bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 512. Game Play Analysis II

512. Game Play Analysis II

Leetcode Solutions

Approach: Subquery and Multi-Value Use of the IN Comparison Operator

Algorithm

  1. Create a subquery that selects the player_id and the minimum event_date for each player by grouping the Activity table by player_id.
  2. In the main query, select player_id and device_id from the Activity table where the combination of player_id and event_date matches the ones found in the subquery.
  3. The IN operator is used to match the tuples of player_id and event_date from the subquery with those in the main Activity table.
  4. The result will be a list of player_id and device_id showing the first device each player logged in with.

erDiagram
    Activity {
        int player_id
        int device_id
        date event_date
        int games_played
        player_id event_date PK
    }

Approach: Window Functions

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...