/*
// Definition for a Node.
class Node {
public int val;
public Node left;
public Node right;
public Node next;
public Node() {}
public Node(int _val) {
val = _val;
}
public Node(int _val, Node _left, Node _right, Node _next) {
val = _val;
left = _left;
right = _right;
next = _next;
}
};
*/
class Solution {
public Node connect(Node root) {
if (root == null) {
return root;
}
Node leftmost = root;
while (leftmost.left != null) {
Node head = leftmost;
while (head != null) {
head.left.next = head.right;
if (head.next != null) {
head.right.next = head.next.left;
}
head = head.next;
}
leftmost = leftmost.left;
}
return root;
}
}
Runtime: 0 ms, faster than 100.00% of Java online submissions for Populating Next Right Pointers in Each Node.
Memory Usage: 38.9 MB, less than 90.44% of Java online submissions for Populating Next Right Pointers in Each Node.
새로운 dat structure만 나오면 셧다운에 들어가는 두뇌...
버리고 새로 갈아끼우고 싶네요^^
냅다 외워~