Solution of a CanJump problem on leetcode