상위 150개 인터뷰중간

코인 체인지 II

'Coin Change II' 문제에 대한 자세한 가이드 및 Python 구현입니다.

문제 설명

중간

다양한 액면가의 동전을 나타내는 정수 배열 동전과 총 금액을 나타내는 정수 금액이 제공됩니다.

해당 금액을 구성하는 조합 수를 반환합니다. 해당 금액을 동전 조합으로 채울 수 없는 경우 0을 반환합니다.

당신은 각 종류의 동전이 무한히 많다고 가정할 수 있습니다.

change(amount: int, coins: List[int]) -> int 함수를 작성하세요.

제약
  • 1 <= len(coins) <= 300
  • 1 <= coins[i] <= 5000
  • 0 <= amount <= 5000

Example 1
Input
amount = 5, coins = [1,2,5]
Output
4
Explanation

There are four ways to make up the amount: 5, 2+2+1, 2+1+1+1, 1+1+1+1+1.

Example 2
Input
amount = 3, coins = [2]
Output
0
Explanation

The amount of 3 cannot be made up with just 2s.

Need a Hint?
세트나 힙과 같은 2D DP 관련 데이터 구조를 사용해 보세요.
Edge Cases to Watch
  • 빈 입력 구조
  • 단일 요소 입력
  • 큰 수치 범위

해결할 준비가 되셨나요?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

편집기에서 열기
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

권장 Python 리소스

관련 대화형 튜토리얼, 치트 시트, 코드 비교를 통해 지식을 확장하세요.