3527. Find the Most Common Response Medium
1/**
2 * [3527] Find the Most Common Response
3 *
4 * You are given a 2D string array responses where each responses[i] is an array of strings representing survey responses from the i^th day.
5 * Return the most common response across all days after removing duplicate responses within each responses[i]. If there is a tie, return the <span data-keyword="lexicographically-smaller-string">lexicographically smallest</span> response.
6 *
7 * <strong class="example">Example 1:
8 * <div class="example-block">
9 * Input: <span class="example-io">responses = [["good","ok","good","ok"],["ok","bad","good","ok","ok"],["good"],["bad"]]</span>
10 * Output: <span class="example-io">"good"</span>
11 * Explanation:
12 *
13 * After removing duplicates within each list, responses = [["good", "ok"], ["ok", "bad", "good"], ["good"], ["bad"]].
14 * "good" appears 3 times, "ok" appears 2 times, and "bad" appears 2 times.
15 * Return "good" because it has the highest frequency.
16 * </div>
17 * <strong class="example">Example 2:
18 * <div class="example-block">
19 * Input: <span class="example-io">responses = [["good","ok","good"],["ok","bad"],["bad","notsure"],["great","good"]]</span>
20 * Output: <span class="example-io">"bad"</span>
21 * Explanation:
22 *
23 * After removing duplicates within each list we have responses = [["good", "ok"], ["ok", "bad"], ["bad", "notsure"], ["great", "good"]].
24 * "bad", "good", and "ok" each occur 2 times.
25 * The output is "bad" because it is the lexicographically smallest amongst the words with the highest frequency.
26 * </div>
27 *
28 * Constraints:
29 *
30 * 1 <= responses.length <= 1000
31 * 1 <= responses[i].length <= 1000
32 * 1 <= responses[i][j].length <= 10
33 * responses[i][j] consists of only lowercase English letters
34 *
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/find-the-most-common-response/
39// discuss: https://leetcode.com/problems/find-the-most-common-response/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44 pub fn find_common_response(responses: Vec<Vec<String>>) -> String {
45 String::new()
46 }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53 use super::*;
54
55 #[test]
56 fn test_3527() {
57 }
58}
59Back
© 2026 bowen.ge All Rights Reserved.