leetcode solution 2