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

Commitddb366b

Browse files
add 1669
1 parent992a059 commitddb366b

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-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+
|1669|[Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1669.java)||Medium|LinedList|
1112
|1668|[Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1668.java)||Easy|String|
1213
|1664|[Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array/)|[Javascript](./javascript/_1664.js)||Medium|Greedy|
1314
|1663|[Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1663.java)||Medium|Greedy|
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importcom.fishercoder.common.classes.ListNode;
4+
5+
publicclass_1669 {
6+
publicstaticclassSolution1 {
7+
publicListNodemergeInBetween(ListNodelist1,inta,intb,ListNodelist2) {
8+
ListNodepre =newListNode(-1);
9+
ListNodelist1Temp =list1;
10+
pre.next =list1Temp;
11+
b -=a;
12+
while (a >1) {
13+
list1Temp =list1Temp.next;
14+
a--;
15+
}
16+
ListNodetail =list1Temp.next;
17+
list1Temp.next =list2;
18+
while (b >0) {
19+
tail =tail.next;
20+
b--;
21+
}
22+
intlength =0;
23+
ListNodetemp2 =list2;
24+
while (temp2 !=null) {
25+
temp2 =temp2.next;
26+
length++;
27+
}
28+
while (length >0) {
29+
list1Temp =list1Temp.next;
30+
length--;
31+
}
32+
list1Temp.next =tail.next;
33+
returnpre.next;
34+
}
35+
}
36+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
packagecom.fishercoder;
2+
3+
importcom.fishercoder.common.classes.ListNode;
4+
importcom.fishercoder.common.utils.LinkedListUtils;
5+
importcom.fishercoder.solutions._1;
6+
importcom.fishercoder.solutions._1669;
7+
importorg.junit.BeforeClass;
8+
importorg.junit.Test;
9+
10+
importstaticorg.junit.Assert.assertArrayEquals;
11+
importstaticorg.junit.Assert.assertEquals;
12+
13+
publicclass_1669Test {
14+
privatestatic_1669.Solution1solution1;
15+
privatestaticListNodelist1;
16+
privatestaticListNodelist2;
17+
privatestaticListNodeexpected;
18+
privatestaticListNodeactual;
19+
20+
@BeforeClass
21+
publicstaticvoidsetup() {
22+
solution1 =new_1669.Solution1();
23+
}
24+
25+
@Test
26+
publicvoidtest1() {
27+
list1 =LinkedListUtils.contructLinkedList(newint[]{0,1,2,3,4,5});
28+
list2 =LinkedListUtils.contructLinkedList(newint[]{1000000,1000001,1000002});
29+
expected =LinkedListUtils.contructLinkedList(newint[]{0,1,2,1000000,1000001,1000002,5});
30+
actual =solution1.mergeInBetween(list1,3,4,list2);
31+
LinkedListUtils.printList(actual);
32+
assertEquals(expected,actual);
33+
}
34+
35+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp