LeetCode Challenge (Python3). Problem#3