easy cpp dp solution
Intuition\n\n\n# Approach\n\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n\nclass Solution {\npublic:\n    int firstDayBeenI
# Intuition\n\n\n# Approach\n\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\npublic:\n    int firstDayBeenInAllRooms(vector<int>& nextVisit) {\n        int n=nextVisit.size();\n        vector<long long>dp(n,0);\n        int i=0;\n        long long days=0;\n        \n        while(i<n){\n         \n            dp[i]=days;\n         \n           if(i==n-1)break;\n             days++;\n            if(nextVisit[i]==i){\n                days=days+1;\n                \n            }\n            else{\n                long long k=(days-dp[nextVisit[i]]);\n\n                days+=(k%1000000007);\n               \n                \n              \n            }\n         \ni++;\n\n        }\n        return (days)%1000000007;\n    }\n};\n// \n```
['C++']