My solution for Leetcode