✔ Python3 Solution | DP
Complexity\n- Time complexity: O(n)\n- Space complexity: O(n)\n\n# Code\n\nclass Solution:\n    def firstDayBeenInAllRooms(self, A):\n        n = len(A)\n      
# Complexity\n- Time complexity: $$O(n)$$\n- Space complexity: $$O(n)$$\n\n# Code\n```\nclass Solution:\n    def firstDayBeenInAllRooms(self, A):\n        n = len(A)\n        mod = 10 ** 9 + 7\n        dp = [0] * (n)\n        for e, i in enumerate(A[:-1], 1):\n            dp[e] = dp[e - 1] + 1\n            dp[e] = (2 * dp[e] - dp[i]) % mod\n        return dp[-1]\n```
['Dynamic Programming', 'Python3']