C++ || DP
\n\n\n# Code\n\n#define ll long long \nint  mod=1e9+7;\nclass Solution {\npublic:\n    int firstDayBeenInAllRooms(vector<int>& nextVisit) {\n          int n=nex
\n\n\n# Code\n```\n#define ll long long \nint  mod=1e9+7;\nclass Solution {\npublic:\n    int firstDayBeenInAllRooms(vector<int>& nextVisit) {\n          int n=nextVisit.size();\n          vector<vector<ll>>dp(n,vector<ll>(2,0));\n          dp[0][0]=2;\n          dp[0][1]=1;\n          for(int i=1;i<n;i++)\n          {   dp[i][1]=dp[i-1][0]+1;\n               if(i==n-1)break;\n              dp[i][0]=(dp[i][1]+(dp[i-1][0]-dp[nextVisit[i]][1])+2)%mod;  \n          }\n          return (dp[n-1][1]+mod-1)%mod;\n    }\n};\n```
['C++']