Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7637038

Browse files
Create 2309.-Greatest-English-Letter-in-Upper-and-Lower-Case.java
Contest 298 problem 1
1 parenta16a161 commit7637038

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//Contest 298 brute-force feel free to share any improvements
2+
classSolution {
3+
publicStringgreatestLetter(Strings) {
4+
HashSet<Integer>set =newHashSet<>();
5+
intans = -1;
6+
for (inti =0;i<s.length();i++) {
7+
if (set.contains((s.charAt(i)-32)) ||set.contains((s.charAt(i)+32)))
8+
ans =Math.max(ans, (int)Character.toUpperCase(s.charAt(i)));
9+
set.add(0+s.charAt(i));
10+
}
11+
returnans==-1?"":(char)ans+"";
12+
}
13+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp