Skip to content

1747. Leetflex Banned Accounts 👍

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
WITH
  LogInfoNeighbors AS (
    SELECT
      *,
      LEAD(ip_address) OVER(
        PARTITION BY account_id
        ORDER BY login
      ) AS next_ip_address,
      LEAD(login) OVER(
        PARTITION BY account_id
        ORDER BY login
      ) next_login
    FROM LogInfo
  )
SELECT DISTINCT account_id
FROM LogInfoNeighbors
WHERE
  next_login <= logout
  AND ip_address != next_ip_address;