5-line 1ms java iterative solution O(n) time O(1) space
public class Solution {\n        public void connect(TreeLinkNode root) {\n            if (root == null) { return; }\n            for (TreeLinkNode head=root; h
    public class Solution {\n        public void connect(TreeLinkNode root) {\n            if (root == null) { return; }\n            for (TreeLinkNode head=root; head.left!=null; head=head.left) {\n                for (TreeLinkNode parent=head; parent!=null; parent=parent.next) {\n                    parent.left.next = parent.right;\n                    if (parent.next != null) { parent.right.next = parent.next.left; }\n                }\n            }\n        }\n    }
['Iterator', 'Java']