linear time solution to canJump