You're analyzing survey data collected over multiple days to identify the most popular response across all participants. Given a 2D string array responses where each responses[i] represents survey responses collected on the i-th day, your task is to find the most frequently occurring response.
Important: Remove duplicate responses within each day before counting (a person can only vote once per day), but the same response can appear on different days.
If there's a tie between multiple responses with the same frequency, return the lexicographically smallest response (alphabetically first).
Example: If Day 1 has ["yes", "no", "yes"] and Day 2 has ["no", "maybe"], after removing duplicates we get ["yes", "no"] and ["no", "maybe"]. The response "no" appears 2 times total, making it the most common.
Input & Output
Visualization
Time & Space Complexity
n days and m average responses per day - each response is processed exactly once
k is the number of unique responses across all days for the frequency hash map
Constraints
- 1 โค responses.length โค 100
- 1 โค responses[i].length โค 100
- 1 โค responses[i][j].length โค 10
- responses[i][j] consists of lowercase English letters only
- Each day has at least one response