leetcode solution in python