Skip to content

Commit 3953cf1

Browse files
author
yennj12
committed
add 116 java
1 parent 1d2d88b commit 3953cf1

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@
833833
110| [Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree/) | [Python](./leetcode_python/Recursion/balanced-binary-tree.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/Recursion/BalancedBinaryTree.java) | _O(n)_| _O(h)_ | Easy |`good trick`,`dfs`,`amazon` ,`fb`, google, top-down, bottom-up recursion| AGAIN************ (6)(MUST)
834834
111| [Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree/)|[Python](./leetcode_python/Recursion/minimum-depth-of-binary-tree.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/Recursion/MinimumDepthOfBinaryTree.java)| _O(n)_ | _O(h)_ | Easy |`good basic`,`dfs`,`BST`,`amazon`,`fb`, LC 104| AGAIN******** (5)
835835
114| [Flatten Binary Tree to Linked List](https://leetcode.com/problems/flatten-binary-tree-to-linked-list/)| [Python](./leetcode_python/Recursion/flatten-binary-tree-to-linked-list.py)| _O(n)_ | _O(h)_ | Medium |`BST`, `dfs`, `M$`, `fb`| AGAIN**** (4)
836-
116| [Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node/)| [Python](./leetcode_python/Recursion/populating-next-right-pointers-in-each-node.py) | _O(n)_ | _O(1)_ | Medium |bfs, dfs, tree, recursion ,AGAIN,`fb`, amazon| AGAIN****** (5)
836+
116| [Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node/)| [Python](./leetcode_python/Recursion/populating-next-right-pointers-in-each-node.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/Recursion/PopulatingNextRightPointersInEachNode.java) | _O(n)_ | _O(1)_ | Medium |bfs, dfs, tree, recursion ,AGAIN,`fb`, amazon| AGAIN****** (5)
837837
117| [Populating Next Right Pointers in Each Node II](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/) |[Python](./leetcode_python/Recursion/populating-next-right-pointers-in-each-node-ii.py), [Java](./leetcode_java/src/main/java/LeetCodeJava/Recursion/PopulatingNextRightPointersInEachNode2.java)| _O(n)_ | _O(h)_ | Medium | `Populating Next Right Pointers in Each Node I`, bfs, linked list, `amazon`, `fb`, google| AGAIN****** (3)
838838
129| [Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers/) |[Python](./leetcode_python/Recursion/sum-root-to-leaf-numbers.py) | _O(n)_ | _O(h)_ | Medium |`trick`,`BST`, `dfs`, `fb`| AGAIN*** (4)
839839
156| [Binary Tree Upside Down](https://leetcode.com/problems/binary-tree-upside-down/) | [Python](./leetcode_python/Recursion/binary-tree-upside-down.py) | _O(n)_ | _O(1)_ | Medium |🔒| AGAIN (not start)

data/progress.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
20250110: 752,117
1+
20250110: 752,117,116
22
20250109: 279,904
33
20250108: 852,692
44
20250107: 247
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package LeetCodeJava.Recursion;
2+
3+
// https://leetcode.com/problems/populating-next-right-pointers-in-each-node/description/
4+
/**
5+
* 116. Populating Next Right Pointers in Each Node
6+
* Solved
7+
* Medium
8+
* Topics
9+
* Companies
10+
* You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:
11+
*
12+
* struct Node {
13+
* int val;
14+
* Node *left;
15+
* Node *right;
16+
* Node *next;
17+
* }
18+
* Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.
19+
*
20+
* Initially, all next pointers are set to NULL.
21+
*
22+
*
23+
*
24+
* Example 1:
25+
*
26+
*
27+
* Input: root = [1,2,3,4,5,6,7]
28+
* Output: [1,#,2,3,#,4,5,6,7,#]
29+
* Explanation: Given the above perfect binary tree (Figure A), your function should populate each next pointer to point to its next right node, just like in Figure B. The serialized output is in level order as connected by the next pointers, with '#' signifying the end of each level.
30+
* Example 2:
31+
*
32+
* Input: root = []
33+
* Output: []
34+
*
35+
*
36+
* Constraints:
37+
*
38+
* The number of nodes in the tree is in the range [0, 212 - 1].
39+
* -1000 <= Node.val <= 1000
40+
*
41+
*/
42+
public class PopulatingNextRightPointersInEachNode {
43+
44+
// V0
45+
// public Node connect(Node root) {
46+
//
47+
// }
48+
49+
// V1
50+
// V2
51+
}

0 commit comments

Comments
 (0)