My solution for LeetCode