solution for leetcode