simplest approach to solve this question
IntuitionThe hint which is we need to visit the n-1th room twice before visiting the nth room.
if we know the time we required to visit the previous room twice
# Intuition
The hint which is we need to visit the n-1th room twice before visiting the nth room.
if we know the time we required to visit the previous room twice we can calculate the time required to visit the current room

# Approach
### Define the state
dp[i][0] -> first times it visites the room i (odd times) optimally
dp[i][1] -> second time it visites the room i (even times) optimally


### define possible transition 
dp[i][0] = dp[i-1][1]+1
dp[i][1] = 2*dp[i][0]-(dp[min(next_visit, i)][0])+1


### reasoning
how dp[i][1]= 2*dp[i][0]-dp[min(next_visit[i], i)][0]+1

1. lets sayyy second time we visit i-1 room at (b-1) second
2. so we visit the the i th room first timt at (b) second
3. after martking i th room we move to one previosly visited room j on b+1 second
4. now we have to calculate time from b+1 second to time at which we will visit the room again 
5. so fist time when we start at j th index let be a we took (b-a) seconds to ith index
6. if we start at b+1th seond we will agian visit the ith sell at b+1+b-a 
7. this equation bcoms 2*b-(a)+1

 Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

 Code
```python3 []
class Solution:
    def firstDayBeenInAllRooms(self, nextVisit: List[int]) -> int:
         # define state
         # dp[i][0] first times it visites the room i (odd times) optimally
         # dp[i][1] second time it visites the room i (even times) optimally


         # define possible transition 
         # dp[i][0] = dp[i-1][1]+1
         # dp[i][1] = 2*dp[i][0]-(dp[min(next_visit, i)][0])+1

         # how dp[i][1]= 2*dp[i][0]-dp[min(next_visit[i], i)][0]+1

         # lets sayyy second time we visit i-1 room at (b-1) second
         # so we visit the the i th room first timt at (b) second
         # after martking i th room we move to one previosly visited room j on b+1 second
         # now we have to calculate time from b+1 second to time at whivh we will visit the room again 
         # so fist time when we start at j th index let be a we took (b-a) seconds to ith index
         # if we start at b+1th seond we will agian visit the ith sell at b+1+b-a 
         # this equation bcoms 2*b-(a)+1
        n = len(nextVisit)
        dp = [[0]*2 for i in range(n)]
        dp[0][0]=0
        dp[0][1]=1
        
        for i in range(1,n):
            dp[i][0]=dp[i-1][1]+1
            dp[i][1]=(2*dp[i][0]-(dp[min(nextVisit[i], i)][0])+1)%(10**9+7)
        return dp[n-1][0]%(10**9+7)

```
['Python3']