Easy solution with comments | beating 97%
Intuition\n- You can only move ( one step forword ) if you have visited current index even times( minimum 2 times every index )\n\n\n# Approach\n- 2 visits if n
# Intuition\n- You can only move ( one step forword ) if you have visited current index even times( minimum 2 times every index )\n\n\n# Approach\n- 2 visits if nextVisit[index]=index \n(kyuki usi index par dobara visit karke current index ke even count ho jayega then, index+1 par visit karenge)\n\n- else part ( nextVisit[index]<index) \n  ( count ko even karne keliye kuch index back jaake dobara anaa hoga )\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n) : dp vector for storing min days to visit that index\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:   \n    int firstDayBeenInAllRooms(vector<int>& nextVisit) {\n        long long n=nextVisit.size(),day=0, mod=1e9+7;\n        vector<long long> min_day_to_visit(n,0);\n        for(int i=0;i<n;i++)\n        {\n            if(i==n-1)  return day;\n            if(nextVisit[i]==i) day+=2;\n            else\n            {\n                int dobara=(day-min_day_to_visit[nextVisit[i]]+mod)%mod;\n                //-> dobara chalna parega nextVisit[index] wali position        \n                //   se current index tak\n                // -> plus piche wale index par jane ke liye 1 din\n                // -> plus index+1 par jane ke liye 1 din\n                day+=((dobara+2)%mod);\n            }\n            day%=mod;\n            min_day_to_visit[i+1]=day;\n        }\n        return -1;\n    }\n};\n```
['Dynamic Programming', 'Greedy', 'C++']