Python Problem Solving Leetcode Javascript