Finish leetcode_512.