Error rendering WebPanel: No renderer found for resource type: velocity Template contents: <meta name="ajs-keyboardshortcut-hash" content="$keyboardShortcutManager.shortcutsHash">

버전 비교

  • 이 줄이 추가되었습니다.
  • 이 줄이 삭제되었습니다.
  • 서식이 변경되었습니다.
코드 블럭
languagepy
titletitleTime Limit Exceeded
linenumberstrue
class Solution:
    def change(self, amount: int, coins: List[int]) -> int:        

        memo = [[0 for _ in range(amount + 1)] for _ in range(amount + 1)]

        def change(amount, coins, memo):

            if amount == 0:
                return 1

            if amount < 0 or len(coins) == 0:
                return 0

            num = coins[-1]

            target = amount - num

            if memo[amount][num]:
                return memo[amount][num]

            a = change(target, coins, memo)
            b = change(amount, coins[:-1], memo)

            memo[amount][num] = a + b

            return memo[amount][num]

        return change(amount - coins[-1], coins, memo) + change(amount, coins[:-1], memo)

...