IBM Interview Question

Coding question in Python with test cases