Python BFS, easy to understand
Using a deque to carry the (array , #round)\n\nin the array, the struct will looks like [[1,5],[2],[4]] the sub_arr with two elements means two player have equa
Using a deque to carry the (array , #round)\n\nin the *array*, the struct will looks like [[1,5],[2],[4]] the sub_arr with two elements means two player have equal chance to next round, one elements means that player will go to next round because he/she is the mid of the previous array or he/she is 1st/2nd player.\nand allcombine in my code is designed to get all pair result form previous round, using backtrack. \n\'\'\'\n   \n    class Solution:\n\t  def earliestAndLatest(self, n: int, firstPlayer: int, secondPlayer: int) -> List[int]:\n         def allcombin(pair):#try to find all combinations for the next round \n            def bt(path,ind): #backtrack similar like LC17\n                if ind == len(pair):\n                    ans.append(path)\n                    return \n                for ele in pair[ind]:\n                    bt(path+[ele],ind+1)\n            ans = []\n            bt([],0)            \n            return ans\n\t\t\t\n        seen = set()  #To avoid duplicate combinations\n        res = []\n        q = deque()\n        start = [i for i in range(1,n+1)]\n        q.append((start,0))\n        while q:\n            arr,rd = q.popleft()\n            pair = []\n            flg = True # to check if 1st and 2nd meet\n            for i in range(len(arr)//2):\n                x,y = arr[i],arr[len(arr)-1-i]\n                if (x,y) == (firstPlayer,secondPlayer):\n\t\t\t\t\t#if x,y matched 1st/2nd, put  this round to res, and return\n                    res.append(rd+1)\n                    flg =  False\n                    break\n                elif x in (firstPlayer,secondPlayer):\n\t\t\t\t\t# x win, so in next round only one player in the pair\n                    pair.append([x])\n                elif y in (firstPlayer,secondPlayer):\n                    pair.append([y])\n                else:\n\t\t\t\t\t# put two players to next round with two elements \n                    pair.append([x,y])\n            if len(arr)%2 ==1:\n                pair.append([arr[len(arr)//2]])\n            if flg: # if 1st/2nd does not in one pair, continue\n                for newarr in allcombin(pair):\n                    sornew = sorted(newarr)\n                    if len(newarr) > 1 and tuple(sornew) not in seen:\n                        seen.add(tuple(sornew))\n                        q.append((sorted(newarr),rd+1))\n        return [min(res),max(res)]\n  \'\'\'             \n                    \n                    \n            \n        \n        \n\t\t
['Breadth-First Search', 'Python']