C++ || DP || O(N)
\nclass Solution {\npublic:\n    typedef long long int64;\n    const int mod = 1e9 + 7;\n    int firstDayBeenInAllRooms(vector<int>& nextVisit) {\n        int n
```\nclass Solution {\npublic:\n    typedef long long int64;\n    const int mod = 1e9 + 7;\n    int firstDayBeenInAllRooms(vector<int>& nextVisit) {\n        int n = nextVisit.size();\n        int64 dp[n];\n        dp[0] = 0LL;\n        for(int i = 1; i < n; i++) {\n            // 1. days to get to i - 1 = dp[i - 1]\n            // 2. days to get to nextVisit[i - 1] from i - 1 = 1\n            // 3. days to get to i - 1 from nextVisit[i - 1] = dp[i - 1] - dp[nextVisit[i - 1]]\n            // 4. days to get to i from i - 1 = 1\n            dp[i] = dp[i - 1] + 1LL + (dp[i - 1] - dp[nextVisit[i - 1]]) + 1LL + mod;\n            dp[i] %= mod;\n        }\n        return dp[n - 1];\n    }\n};\n```
[]