[JavaScript] DFS + Bitwise
javascript\n var earliestAndLatest = function(numPlayers, firstPlayer, secondPlayer) {\n    let minRounds = Infinity;\n    let maxRounds = 0;\n    const dfs = (
```javascript\n var earliestAndLatest = function(numPlayers, firstPlayer, secondPlayer) {\n    let minRounds = Infinity;\n    let maxRounds = 0;\n    const dfs = (playersEliminated, numRounds) => {\n        \n        // find all the combinations for this round starting with the\n        // current players that are eliminated.  We will move the 2 pointers\n        // from opposite ends inwards until we find players that aren\'t eliminated\n        // and then create new possible results of this current round.\n        // Every loop in the while loop will correspond to a competition between player\n        // i and j while roundResults will hold all possible round results.\n        let roundResults = [playersEliminated];\n        let i = 1;\n        let j = numPlayers;\n        while (true) {\n            // find players that aren\'t eliminated\n            while (playersEliminated & (1 << i)) i++;\n            while (playersEliminated & (1 << j)) j--;\n            // if we are at or past the same player, we can stop\n            if (i >= j) break;\n            // if during this round the first and second player are playing\n            // against each other, we can record the results and stop searching.\n            if (i === firstPlayer && j === secondPlayer) {\n                minRounds = Math.min(minRounds, numRounds);\n                maxRounds = Math.max(maxRounds, numRounds);\n                return;\n            } \n            \n            // create new round results by eliminating player as long as it isn\'t\n            // the first or second player.\n            // roundResult | (1 << i)  means we eliminated player i (player i lost)\n            const newRoundResults = [];\n            if (j !== firstPlayer && j !== secondPlayer) {\n                for (const roundResult of roundResults) {\n                    newRoundResults.push(roundResult | (1 << j));\n                }\n            } \n            if (i !== firstPlayer && i !== secondPlayer){\n                for (const roundResult of roundResults) {\n                    newRoundResults.push(roundResult | (1 << i));\n                }\n            }\n            // move the pointers inwards to find next matching players\n            i++;\n            j--;\n            // save the new round results to round results\n            roundResults = newRoundResults;\n        }\n        \n        // if we have exhausted all round results return as the base case\n        if (!roundResults.length) return;\n        \n        // add a round for the next round and try each result to see if it will\n        // update the max and min number of rounds\n        numRounds++;\n        roundResults.forEach((roundResult) => dfs(roundResult, numRounds));\n    }\n    dfs(0,1)\n    return [minRounds, maxRounds];\n};\n```
['Bit Manipulation', 'Depth-First Search', 'JavaScript']