알고리즘/알고리즘 문제 복기

Leet code - 55. Jump Game

내일도무사히 2021. 3. 26. 09:31

leetcode.com/problems/jump-game/

 

Jump Game - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

Question.

 

Answer

 

 

이전에 점프게임II를 풀어서 그런지 비교적 쉽게 풀어냈다.

 

farthest는 가장 멀리 도달한 인덱스 값이며

nums[i]가 0이라면 그 값에 도달하기 전의 farthest를 체크하여

만약 zero_index보다 멀리 갈 수 있다면 jumpable을 true로 놔두고 

아니라면 jumpable를 false로 설정한다.