LeetCode Implementation in Python