diff --git a/random.js b/random.js index 07cbaf9..2cf2b7f 100644 --- a/random.js +++ b/random.js @@ -77,7 +77,12 @@ const getLeaves = (node)=>{ if(threePathResult.length === 0){ return twoPathResult; } else { - return [twoPathResult, threePathResult] + if(Number.isInteger(twoPathResult[0])){ + return [twoPathResult, threePathResult] + } else { + twoPathResult.push(threePathResult) + return twoPathResult; + } } } const leaves = getLeaves(tree);