경쟁 프로그래밍쉬움

최소 점프

'최소 점프' 문제에 대한 자세한 가이드 및 Python 구현.

문제 설명

쉬움

인덱스 0부터 시작하여 arr의 마지막 인덱스에 도달하기 위한 최소 점프 수를 찾는 함수 min_jumps(arr)을 작성하세요. 배열의 각 요소는 해당 위치로부터의 최대 점프 길이를 나타냅니다. 마지막 인덱스에 도달하는 것이 불가능하면 -1을 반환합니다.

제약
  • 1 <= len(arr) <= 10^4
  • 0 <= arr[i] <= 10^4

Example 1
Input
min_jumps([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9])
Output
3
Explanation

Jump from index 0 to 1 (value 3), then jump to index 4 (value 9), and then jump to the last index.

Example 2
Input
min_jumps([1, 1, 1, 1, 1])
Output
4
Explanation

Jump one by one from start to end, requiring 4 jumps.

Need a Hint?
세트나 힙과 같은 동적 프로그래밍 관련 데이터 구조를 사용해 보세요.
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 리소스

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