Leetcode 552 Solution
This article provides solution to leetcode question 552 (student-attendance-record-ii)
Access this page by simply typing in "lcs 552" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/student-attendance-record-ii
Solution
class Solution:
def checkRecord(self, n: int) -> int:
v00 = 1
v10 = 1
v20 = 1
v01 = 1
v11 = 1
v21 = 1
for i in range(1, n + 1):
nv00 = (v00 + v10 + v01) % 1000000007
nv10 = (v00 + v20 + v01) % 1000000007
nv20 = (v00 + v01) % 1000000007
nv01 = (v01 + v11) % 1000000007
nv11 = (v01 + v21) % 1000000007
nv21 = (v01) % 1000000007
v00 = nv00
v10 = nv10
v20 = nv20
v01 = nv01
v11 = nv11
v21 = nv21
return v00