Java solution got TLE but it was accepted 5 days ago.

  • 0

    Hello As mentioned above, I noticed that my java solution which was accepted 5 days ago got TLE by a large data test case.

    Here is my solution

    public void connect(TreeLinkNode root) {
            while(root!=null && root.left!=null) {
                TreeLinkNode cur = root;
                while(cur!=null) {
                    if(!=null) {
           = cur.right;
                    cur =;
                root = root.left;

    I took reference from other answers. Anyone has idea to improve this?


Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.