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

Commitfb0aed3

Browse files
add 1768
1 parent9b2d37f commitfb0aed3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-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+
|1768|[Merge Strings Alternately](https://leetcode.com/problems/merge-strings-alternately/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1768.java)||Easy|String|
1112
|1765|[Map of Highest Peak](https://leetcode.com/problems/map-of-highest-peak/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1765.java)||Medium|BFS, Graph|
1213
|1764|[Form Array by Concatenating Subarrays of Another Array](https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1764.java)||Medium|Array, Greedy|
1314
|1763|[Longest Nice Substring](https://leetcode.com/problems/longest-nice-substring/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1763.java)||Easy|String|
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_1768 {
4+
publicstaticclassSolution1 {
5+
publicStringmergeAlternately(Stringword1,Stringword2) {
6+
StringBuildersb =newStringBuilder();
7+
inti =0,j =0;
8+
for (;i <word1.length() &&j <word2.length(); ) {
9+
sb.append(word1.charAt(i++));
10+
sb.append(word2.charAt(j++));
11+
}
12+
while (i <word1.length()) {
13+
sb.append(word1.charAt(i++));
14+
}
15+
while (j <word2.length()) {
16+
sb.append(word2.charAt(j++));
17+
}
18+
returnsb.toString();
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp