think-cell Interview Question

Write a function in C++ that implements a given functionality.