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

Commitc58a143

Browse files
add 430
1 parentf82c7fe commitc58a143

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ _If you like this project, please leave me a star._ ★
850850
|435|[Non-overlapping Intervals](https://leetcode.com/problems/non-overlapping-intervals/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_435.java) | |Medium| Greedy
851851
|434|[Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_434.java)||Easy|
852852
|432|[All O`one Data Structure](https://leetcode.com/problems/all-oone-data-structure/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_432.java)| |Hard| Design
853+
|430|[Flatten a Multilevel Doubly Linked List](https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_430.java)| |Medium|LinkedList, DFS, Doubly-Linked List
853854
|429|[N-ary Tree Level Order Traversal](https://leetcode.com/problems/n-ary-tree-level-order-traversal/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_429.java)| |Easy| BFS, Tree
854855
|425|[Word Squares](https://leetcode.com/problems/word-squares/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_425.java)| |Hard| Trie, Backtracking, Recursion
855856
|424|[Longest Repeating Character Replacement](https://leetcode.com/problems/longest-repeating-character-replacement/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_424.java)| | Medium| Sliding Window
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_430 {
4+
publicstaticclassSolution1 {
5+
/**
6+
* credit: https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list/solution/
7+
*/
8+
publicNodeflatten(Nodehead) {
9+
if (head ==null) {
10+
returnnull;
11+
}
12+
Nodepre =newNode(-1,null,head,null);
13+
dfs(pre,head);
14+
pre.next.prev =null;
15+
returnpre.next;
16+
}
17+
18+
privateNodedfs(Nodeprev,Nodecurr) {
19+
if (curr ==null) {
20+
returnprev;
21+
}
22+
curr.prev =prev;
23+
prev.next =curr;
24+
25+
Nodenext =curr.next;
26+
Nodetail =dfs(curr,curr.child);
27+
curr.child =null;
28+
returndfs(tail,next);
29+
}
30+
}
31+
32+
publicstaticclassNode {
33+
publicintval;
34+
publicNodeprev;
35+
publicNodenext;
36+
publicNodechild;
37+
38+
publicNode(intval,Nodeprev,Nodenext,Nodechild) {
39+
this.val =val;
40+
this.prev =prev;
41+
this.next =next;
42+
this.child =child;
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp