Anonymous Interview Question

Write the code either in c++ or python