Hi, I am wondering if time complexity should be O(N+NlogK)? Hashmap initialization should be O(N) instead of O(NlogN). See the time complexity explanation in “Top K Frequent Number” problem, which is O(N+N∗logK) and O(N) for hashmap initialization.
Course: Grokking the Coding Interview: Patterns for Coding Questions - Learn Interactively
Lesson: Maximum Distinct Elements (medium) - Grokking the Coding Interview: Patterns for Coding Questions