Python 4 Lines Solution Faster than 100%
\n\nLet dist[i] be the minimum steps you need to visit i; dist[0]=0. To reach i, you need first  reach i-1, take 1 day back to nextVisit[i-1], get from nextVisi
![image](https://assets.leetcode.com/users/images/2e750513-c5bb-434a-809c-8aea090e01e6_1630815924.9723213.png)\n\nLet `dist[i]` be the minimum steps you need to visit `i`; `dist[0]=0`. To reach `i`, you need first  reach `i-1`, take 1 day back to `nextVisit[i-1]`, get from `nextVisit[i-1]` to `i-1`, and finally use 1 day to reach `i`. Meanwhile, the days needed from `nextVisit[i-1]` to `i-1` is `dist[i-1]-dist[nextVist[i-1]]`. So\n```\ndist[i]=dist[i-1]+1+dist[i-1]-dist[nextVist[i-1]]+1\n```\nFinally the code is\n```\ndef firstDayBeenInAllRooms(self, nextVisit: List[int]) -> int:\n    dist=[0]*len(nextVisit)\n    for i in range(1,len(nextVisit)):\n        dist[i]=(2*dist[i-1]-dist[nextVisit[i-1]]+2)%1000000007\n    return dist[-1]\n```\n\n\n
[]