Python solution for LeetCode problems