1904. Second Largest Digit in a String
2026/1/12小于 1 分钟约 208 字
1904. Second Largest Digit in a String
难度: Easy
题目描述
Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.
An alphanumericstring is a string consisting of lowercase English letters and digits.
Example 1:
Input: s = "dfa12321afd" Output: 2 Explanation: The digits that appear in s are [1, 2, 3]. The second largest digit is 2.
Example 2:
Input: s = "abc1111" Output: -1 Explanation: The digits that appear in s are [1]. There is no second largest digit.
Constraints:
1 <= s.length <= 500sconsists of only lowercase English letters and digits.
解题思路
代码实现
解决方案
java
class Solution {
public int secondHighest(String s) {
}
}