Easy DP C++
class Solution {\npublic:\n    int firstDayBeenInAllRooms(vector& arr) {\n        \n        int mod = 1e9+7;\n        int n = arr.size();\n        vector dp(n )
class Solution {\npublic:\n    int firstDayBeenInAllRooms(vector<int>& arr) {\n        \n        int mod = 1e9+7;\n        int n = arr.size();\n        vector<int> dp(n );\n        \n        // the only way to visit room i is through i - 1\n        \n        for(int i = 1; i<n; i++)\n        {\n            dp[i] = ( 2*dp[i-1] - dp[arr[i-1]] + 2 + mod)%mod;\n        \n        }\n        \n        return dp[n-1];\n        \n        \n        \n    }\n};
[]