No one has replied
Interesting theory, but I don't think that's it. I added String t = "" + i; to your loop, which creates a new string each iteration and does slow down your time from 4ms to 20ms, still well within the allowed time.
But you're close to the correct reason.
Level order is indeed not the answer, [4,1,null,2,null,3] is the test case where it fails.
Thanks! It helped!
@bruce01j I did not understand why i should put the tail.next = null
could you explain it to me ?
thanks a lot
Thanks for reporting. I reduced the last test case size, and your code is now accepted.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.