solution to leetcode