(C++) 1997. First Day Where You Have Been in All the Rooms
\n\nclass Solution {\npublic:\n    int firstDayBeenInAllRooms(vector<int>& nextVisit) {\n        const int MOD = 1\'000\'000\'007; \n        int n = nextVisit.s
\n```\nclass Solution {\npublic:\n    int firstDayBeenInAllRooms(vector<int>& nextVisit) {\n        const int MOD = 1\'000\'000\'007; \n        int n = nextVisit.size(); \n        vector<long> odd(n), even(n); \n        even[0] = 1; \n        for (int i = 1; i < n; ++i) {\n            odd[i] = (even[i-1] + 1) % MOD; \n            even[i] = (2*odd[i] - odd[nextVisit[i]] + 1 + MOD) % MOD; \n        }\n        return odd.back(); \n    }\n};\n```
['C']