Finish leetcode_517.