Finish leetcode_5111.