A help desk logs complaint categories in arrival order in log. Return the category with the most complaints. If several categories tie for the highest count, return the one that reached that count first in the log. Return "" for an empty log.
Examples
Input: log = ["wifi", "noise", "noise", "wifi"]
Output: "noise"
Explanation: both reach 2, but "noise" reaches 2 at position 2, before "wifi" does at position 3.
Input: log = ["a", "b", "b", "a", "a"]
Output: "a"
Constraints
0 <= len(log) <= 10**5- Target complexity: O(n) time, one pass.
Goals
- Track the leader while counting in a single pass
- Implement a time-based tie rule that a post-hoc sort cannot express