Leetcode Problem Solving Python