Skip to content

Commit 7a9a74f

Browse files
authored
Improved task 1796.
1 parent 5435c33 commit 7a9a74f

File tree

1 file changed

+28
-1
lines changed
  • src/main/java/g1701_1800/s1796_second_largest_digit_in_a_string

1 file changed

+28
-1
lines changed
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
1796\.
1+
1796\. Second Largest Digit in a String
2+
3+
Easy
4+
5+
Given an alphanumeric string `s`, return _the **second largest** numerical digit that appears in_ `s`_, or_ `-1` _if it does not exist_.
6+
7+
An **alphanumeric** string is a string consisting of lowercase English letters and digits.
8+
9+
**Example 1:**
10+
11+
**Input:** s = "dfa12321afd"
12+
13+
**Output:** 2
14+
15+
**Explanation:** The digits that appear in s are [1, 2, 3]. The second largest digit is 2.
16+
17+
**Example 2:**
18+
19+
**Input:** s = "abc1111"
20+
21+
**Output:** -1
22+
23+
**Explanation:** The digits that appear in s are [1]. There is no second largest digit.
24+
25+
**Constraints:**
26+
27+
* `1 <= s.length <= 500`
28+
* `s` consists of only lowercase English letters and/or digits.

0 commit comments

Comments
 (0)