Why TLE? no formula


  • -2
    W
    function win(n, round) {
    round++
    if(n <= 0)
    	return false
    else if(n > 0 && n <= 3)
    	return (round % 2 !== 0)
    else if(n > 3){
        if(round % 2 === 0) {
        	return (win(n-1, round) && win(n-2, round) && win(n-3, round))
        } else {
        	return (win(n-1, round) || win(n-2, round) || win(n-3, round))
        }
    }
    

    }
    function canWinNim(n) {
    return win(n, 0)
    }

    no formula


Log in to reply
 

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