Python DP
dp[i][0] the first day to arrive at room i with even times.\ndp[i][1] the first day to arrive at room i with odd times.\nThe idea of dp transition is following:
dp[i][0] the first day to arrive at room i with even times.\ndp[i][1] the first day to arrive at room i with odd times.\nThe idea of dp transition is following:\n1. **dp[i][1] = dp[i-1][0]+1**, to arrive at room i, we must have visited room i-1 even times.\n2. To calculate **dp[i][0]**,  first of all we should arrive at state **dp[i][1]**, then we move to room nextVisit[i], then go back to room i eventually. And it needs **dp[i][1]- dp[nextVisit[i]][1]** days. \n3. **dp[i][0] = dp[i][1] + dp[i][1]- dp[nextVisit[i]] +1**, \n```\nclass Solution:\n    def firstDayBeenInAllRooms(self, nextVisit: List[int]) -> int:\n        n = len(nextVisit)\n        dp = [[0 for i in range(2)] for i in range(n)]\n        dp[0][1] = 0\n        dp[0][0] = 1\n        \n        for i in range(1,n):\n            dp[i][1] = dp[i-1][0]+1\n            if nextVisit[i]==i:\n                dp[i][0] = (dp[i][1]+1)%(10**9+7)\n            else:\n                dp[i][0] = (dp[i][1] + dp[i][1] - dp[nextVisit[i]][1] + 1)%(10**9+7)\n        \n        return dp[n-1][1]%(10**9+7)\n\n```
[]