Leetcode Problem 1817. Finding the Users Active Minutes

1817. Finding the Users Active Minutes

Leetcode Solutions

Using HashMap and HashSet

  1. Initialize a HashMap userToMinutes to map user IDs to a HashSet of unique minutes.
  2. Iterate over each entry in the logs array.
    • For each log entry, add the minute to the HashSet corresponding to the user ID in the HashMap.
  3. Initialize an array answer of size k to store the count of users with each UAM.
  4. Iterate over the values of the HashMap.
    • For each HashSet, increment the count at the index corresponding to the size of the HashSet minus one in the answer array.
  5. Return the answer array.
UML Thumbnail

Sorting Logs and Counting Unique Minutes

Ask Question

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

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...