educative.io

Educative

Why I need these lines of code

‘’’ if (root === null) {
return sequence.length === 0;
}
‘’’
If there is no root or sequence array, as per code, it should give true but why the result is false?

Hi @Sunitha_Nela,

The commands in the last two lines of the solution code are trying to find a path sequence i.e., 1,0,7 and 1,0,6. If the tree only has NULL in it that means both path sequences are absent in the tree and hence the result will be false.