The solution for the problems on the leetcode.