C++ || Easy Solution
\n#define ll long long int\nclass Solution {\npublic:\n    int firstDayBeenInAllRooms(vector<int>& next) {\n        ll n = next.size();\n        ll mod = 1e9+7;
```\n#define ll long long int\nclass Solution {\npublic:\n    int firstDayBeenInAllRooms(vector<int>& next) {\n        ll n = next.size();\n        ll mod = 1e9+7;\n        vector<ll>time(n);\n        vector<ll>pref(n);\n        pref[0]=2;\n        time[0]=2;\n        ll arr = 2;\n        for(ll i=1; i<n; i++){\n            if(i==n-1)\n                return arr%mod;\n            ll p = next[i];\n            ll end = (arr+1+(pref[i-1]-((p==0) ? 0 : pref[p-1]))+mod)%mod;\n            time[i]=(end-arr+1+mod)%mod;\n            pref[i] = (pref[i-1]+time[i]+mod)%mod;\n            arr=  (end+1+mod)%mod;\n        }\n        return arr;\n    }\n};\n```
[]