Leetcode Dynamic Array Problems In Python A Function