Faster than 50% time, 100% Space in C++ and same solution gives a TLE in Python ;)
\nclass Solution {\npublic:\n    vector<int> earliestAndLatest(int n, int first, int second) {\n        int minRound = INT_MAX, maxRound = INT_MIN;\n\n        f
```\nclass Solution {\npublic:\n    vector<int> earliestAndLatest(int n, int first, int second) {\n        int minRound = INT_MAX, maxRound = INT_MIN;\n\n        function<void(int,int,int,int)> dfs = \n            [&](int deadMask,int i,int j, int curRound) {\n            \n            while (i < j and deadMask & (1<<i)) // \'i\' is dead warrior, try next\n                i += 1;\n        \n            while (i < j and deadMask & (1<<j)) // \'j\' is dead warrior, try next\n                j -= 1;\n\n            if (i >= j) // end of round, no more fights possible\n                dfs(deadMask, 1, n, curRound + 1);\n\n            else if (i == first and j == second) // BATTLE OF THE IMMORTALS\n                minRound = min(curRound,minRound),\n                maxRound = max(curRound,maxRound);\n            \n            else{ // BATTLE includes a mortal  \n                if (i != first and i != second) // \'i\' is MORTAL, he may die\n                    dfs(deadMask | (1<<i), i+1, j-1, curRound);\n                if (j != first and j != second) // \'j\' is MORTAL, he may die\n                    dfs(deadMask | (1<<j), i+1, j-1, curRound);\n\n            }\n        };\n        dfs(0,1,n,1);\n        return {minRound, maxRound};\n    }\n};\n```\n\n```py\nclass Solution:\n    def earliestAndLatest(self, n, first, second) -> List[int]:\n        minRound, maxRound = math.inf, -math.inf\n        def dfs(deadMask, i, j, curRound):\n            nonlocal minRound, maxRound\n            \n            while i < j and deadMask & (1<<i): # \'i\' is dead warrior, try next\n                i += 1\n        \n            while i < j and deadMask & (1<<j): # \'j\' is dead warrior, try next\n                j -= 1\n\n            if i >= j: # end of round, no more fights possible\n                dfs(deadMask, 1, n, curRound + 1)\n\n            elif i == first and j == second: # BATTLE OF THE IMMORTALS\n                minRound = min(curRound,minRound)\n                maxRound = max(curRound,maxRound)\n            \n            else: # Proceed with a BATTLE with a mortal  \n                if i != first and i != second: # \'i\' is MORTAL, he may die\n                    dfs(deadMask | (1<<i), i+1, j-1, curRound)\n                if j != first and j != second: # \'j\' is MORTAL, he may die\n                    dfs(deadMask | (1<<j), i+1, j-1, curRound)\n                    \n        dfs(0,1,n,1)\n        return minRound, maxRound\n```\n\nAll ideas from @votrubac [discuss post](https://leetcode.com/problems/the-earliest-and-latest-rounds-where-players-compete/discuss/1268539/Recursion)\n
['Depth-First Search', 'Recursion', 'C', 'Bitmask', 'Python']