leetcode implementation in python