Skip to content

Commit 6160937

Browse files
authored
Update 1997.First-Day-Where-You-Have-Been-in-All-the-Rooms.cpp
1 parent 665bf0f commit 6160937

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
class Solution {
22
long dp[100000];
33
long M = 1e9+7;
4-
int n;
54
public:
65
int firstDayBeenInAllRooms(vector<int>& nextVisit)
76
{
87
n = nextVisit.size();
98
dp[0] = 0;
10-
dp[1] = 2;
11-
long ret = 2;
12-
for (int i=1; i<n-1; i++)
9+
for (int i=0; i<n-1; i++)
1310
{
1411
int prev = nextVisit[i];
1512
dp[i+1] = dp[i] + (dp[i]-dp[prev] + M +1) % M + 1;
1613
dp[i+1] %= M;
1714
}
1815
return dp[n-1];
1916
}
20-
21-
2217
};

0 commit comments

Comments
 (0)