Solution for LeetCode OJ