Skip to content

Commit f90d328

Browse files
committed
Runtime: 1881 ms (Top 9.44%) | Memory: 23.9 MB (Top 80.86%)
1 parent 5b75dae commit f90d328

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Runtime: 1881 ms (Top 9.44%) | Memory: 23.9 MB (Top 80.86%)
12
from functools import lru_cache, cache
23

34
class Solution:
@@ -8,11 +9,11 @@ def dp(i=0, m1=0, m2=0): # mask1, mask2
89
return 0
910
ans = 0
1011
for s in range(numSlots):
11-
if m2 & (1 << s) == 0: # i.e. 0b0?, implying the slot is not full
12+
if m2 & (1 << s) == 0: # i.e. 0b0?, implying the slot is not full
1213
if m1 & (1 << s) == 0: # 0b00 + 1 => 0b01
13-
nm1 = m1 | (1 << s); nm2 = m2
14+
nm1 = m1 | (1 << s); nm2 = m2
1415
else: # 0b01 + 1 => 0b10
1516
nm1 = m1 & ~(1 << s); nm2 = m2 | (1 << s)
1617
ans = max(ans, dp(i + 1, nm1, nm2) + ((s + 1) & nums[i])) # s + 1 is the actual slot no.
1718
return ans
18-
return dp()
19+
return dp()

0 commit comments

Comments
 (0)