Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Mohammed Dh Abbas
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