a slightly faster linear time solution to canJump