Back to course home
0% completed
Vote For New Content
Simple DP solution
Mohammed Dh Abbas
Oct 18, 2024
class Solution: def countWays(self, n): def dp(acc, memo): if acc in memo: return memo[acc] if acc == n: return 1 if acc > n: return 0 result = dp(acc + 1, memo) + dp(acc + 3, memo) + dp(acc + 4, memo) memo[acc] = result return result return dp(0, {})
0
0
Comments
Comments
On this page