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

Commitbbdbf55

Browse files
add 2129
1 parentf3bc0e2 commitbbdbf55

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|2129|[Capitalize the Title](https://leetcode.com/problems/capitalize-the-title/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2129.java)||Easy||
1112
|2126|[Destroying Asteroids](https://leetcode.com/problems/destroying-asteroids/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2126.java)||Medium||
1213
|2125|[Number of Laser Beams in a Bank](https://leetcode.com/problems/number-of-laser-beams-in-a-bank/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2125.java)||Medium||
1314
|2124|[Check if All A's Appears Before All B's](https://leetcode.com/problems/check-if-all-as-appears-before-all-bs/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2124.java)||Easy||
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.Locale;
4+
5+
publicclass_2129 {
6+
publicstaticclassSolution1 {
7+
publicStringcapitalizeTitle(Stringtitle) {
8+
String[]words =title.split("\\ ");
9+
StringBuildersb =newStringBuilder();
10+
for (inti =0;i <words.length;i++) {
11+
Stringtmp =words[i].toLowerCase(Locale.ROOT);
12+
if (words[i].length() <=2) {
13+
sb.append(tmp);
14+
}else {
15+
sb.append(Character.toUpperCase(tmp.charAt(0)) +tmp.substring(1));
16+
}
17+
if (i <words.length -1) {
18+
sb.append(" ");
19+
}
20+
}
21+
returnsb.toString();
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp