C++ | easy 🔥🔥Prefix Sum 💯✌️
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int firstDayBeenInAllRooms(vector<int>& v) {\n        int n = v.size();\n        if (n == 1) return 0;\n\n        const int MOD = 1000000007;\n        vector<long long> pre(n + 1, 0);\n        pre[0] = 0;\n        pre[1] = 2;\n\n        for (int i = 2; i < n; i++) {\n            pre[i] = (pre[i - 1] + 2) % MOD;\n            pre[i] = (pre[i] + (pre[i - 1] - pre[v[i - 1]] + MOD) % MOD) % MOD;\n        }\n\n        return (pre[n - 1] + MOD) % MOD;\n    }\n};\n\n```
['Prefix Sum', 'C++']