Codes for leetcode.