code for Leetcode 150 problems