Simple DP Explained Python
Whenever u visit a node for the first time, you have to visit it again before moving forward. \nTime it takes to visit it again = curr_time - FirstTime[nex] + 1
Whenever u visit a node for the first time, you have to visit it again before moving forward. \nTime it takes to visit it again = curr_time - FirstTime[nex] + 1\nnex represents nextVisit[c_node],\nnex <= c_node, so u must have visited nex before c_node unless nex is c_node. \n\n```\ndef firstDayBeenInAllRooms(self, nextVisit: List[int]) -> int:\n    n = len(nextVisit)\n    MOD = 1000000007\n\n    time = [0]*n\n    c_time = -1\n    for i in range(n):\n        c_time += 1\n        c_time %= MOD\n        time[i] = c_time \n        \n        c_time += c_time - time[nextVisit[i]] + 1\n    \n    return time[n-1]\n```
['Dynamic Programming', 'Python']