Stepping Stones Game

  • + 0 comments

    Typescript -- time complexity O(1)!

    function solve(n: number): string {
        const moves = (Math.sqrt(8 * n + 1) - 1) / 2;
        return Number.isInteger(moves) ? 'Go On Bob ' + moves : 'Better Luck Next Time';
    }