I have resolved this problem using DFS by C++, it take 6ms. This solution only beat 15%, because there are other take only 3ms. That solution use a vector to store value of traveled node and separate level from level by using a TreeNode flag(0). It's mean that TreeNode with val == 0 will exclude from all input data.
So, are there any pre-defined condition of input?