Practice The Latest Login in 2020
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Tables: Logins(user_id INT, time_stamp DATETIME). Logins has key (user_id, time_stamp). Return user_id and last_stamp for each user who logged in during calendar year 2020. last_stamp is that user's latest timestamp within 2020; a later login in another year must not replace it. Exclude users without a 2020 login. Output order is unrestricted.
Source: The Latest Login in 2020 on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Logins table: +---------+---------------------+ | user_id | time_stamp | +---------+---------------------+ | 6 | 2020-06-30 15:06:07 | | 6 | 2021-04-21 14:06:06 | | 6 | 2019-03-07 00:18:15 | | 8 | 2020-02-01 05:10:53 | | 8 | 2020-12-30 00:46:50 | | 2 | 2020-01-16 02:49:50 | | 2 | 2019-08-25 07:59:08 | | 14 | 2019-07-14 09:00:00 | | 14 | 2021-01-06 11:59:59 | +---------+---------------------+
+---------+---------------------+ | user_id | last_stamp | +---------+---------------------+ | 6 | 2020-06-30 15:06:07 | | 8 | 2020-12-30 00:46:50 | | 2 | 2020-01-16 02:49:50 | +---------+---------------------+
Related LeetCode Problems
Practice more problems similar to The Latest Login in 2020.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.