Leetcode Problem 4 Solution In Python A Function