We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
给你一个混合字符串 s ,请你返回 s 中 第二大 的数字,如果不存在第二大的数字,请你返回 -1 。
混合字符串 由小写英文字母和数字组成。
输入:s = "dfa12321afd" 输出:2 解释:出现在 s 中的数字包括 [1, 2, 3] 。第二大的数字是 2 。
输入:s = "abc1111" 输出:-1 解释:出现在 s 中的数字只包含 [1] 。没有第二大的数字。
The text was updated successfully, but these errors were encountered:
遍历一遍即可 func secondHighest(s string) int { ret := [2]int{-1,-1} for i := 0; i < len(s); i++ { diff := int(s[i] - '0') if diff <= 9 { if diff > ret[0] { ret[1] = ret[0] ret[0] = diff } else if diff > ret[1] && diff != ret[0]{ ret[1] = diff } } } return ret[1] }
Sorry, something went wrong.
No branches or pull requests
给你一个混合字符串 s ,请你返回 s 中 第二大 的数字,如果不存在第二大的数字,请你返回 -1 。
混合字符串 由小写英文字母和数字组成。
示例 1:
示例 2:
提示:
The text was updated successfully, but these errors were encountered: