Aarki interview question

Q: Write a function in Python that solves this problem...