Python O(n) DP Solution
\nclass Solution:\n    def firstDayBeenInAllRooms(self, nextVisit: List[int]) -> int:\n        numRooms, day, MOD = len(nextVisit), 0, 1000000007\n        daysT
```\nclass Solution:\n    def firstDayBeenInAllRooms(self, nextVisit: List[int]) -> int:\n        numRooms, day, MOD = len(nextVisit), 0, 1000000007\n        daysToGetPast = [0] * numRooms\n        for i in range(numRooms - 1):\n            if nextVisit[i] == i:\n                day = (day + 2) % MOD\n            else:\n                timeFromBegToEnterRoom = 0\n                if nextVisit[i] > 0:\n                    timeFromBegToEnterRoom = daysToGetPast[nextVisit[i] - 1]\n                day = (((2*(day % MOD)) % MOD - (timeFromBegToEnterRoom % MOD)) + MOD) % MOD\n                day = (day + 2) % MOD\n            daysToGetPast[i] = day % MOD\n        return daysToGetPast[numRooms - 2]\n```
['Dynamic Programming', 'Python']