1796. Second Largest Digit in a String Easy
1/**
2 * [1796] Second Largest Digit in a String
3 *
4 * Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.
5 * An alphanumeric string is a string consisting of lowercase English letters and digits.
6 *
7 * Example 1:
8 *
9 * Input: s = "dfa12321afd"
10 * Output: 2
11 * Explanation: The digits that appear in s are [1, 2, 3]. The second largest digit is 2.
12 *
13 * Example 2:
14 *
15 * Input: s = "abc1111"
16 * Output: -1
17 * Explanation: The digits that appear in s are [1]. There is no second largest digit.
18 *
19 *
20 * Constraints:
21 *
22 * 1 <= s.length <= 500
23 * s consists of only lowercase English letters and/or digits.
24 *
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/second-largest-digit-in-a-string/
29// discuss: https://leetcode.com/problems/second-largest-digit-in-a-string/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34 pub fn second_highest(s: String) -> i32 {
35 0
36 }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43 use super::*;
44
45 #[test]
46 fn test_1796() {
47 }
48}
49
Back
© 2025 bowen.ge All Rights Reserved.