Skip to content

Commit b7596bf

Browse files
committed
Runtime: 760 ms (Top 68.15%) | Memory: 14.5 MB (Top 56.05%)
1 parent d52b858 commit b7596bf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Runtime: 760 ms (Top 68.15%) | Memory: 14.5 MB (Top 56.05%)
12

23
class Solution:
34
def tallestBillboard(self, rods: List[int]) -> int:
@@ -6,15 +7,15 @@ def tallestBillboard(self, rods: List[int]) -> int:
67
for x in rods:
78
nxt = dp.copy()
89
for d, y in dp.items():
9-
# init state
10-
# ------|----- d -----| # tall side
11-
# - y --| # low side
10+
# init state
11+
# ------|----- d -----| # tall side
12+
# - y --| # low side
1213

13-
# put x to tall side
14+
# put x to tall side
1415
# ------|----- d -----|---- x --|
1516
# - y --|
1617
nxt[d + x] = max(nxt.get(x + d, 0), y)
17-
18+
1819
nxt[abs(d - x)] = max(nxt.get(abs(d - x), 0), y + min(d, x))
1920
dp = nxt
20-
return dp[0]
21+
return dp[0]

0 commit comments

Comments
 (0)