Anonymous interview question

Write the code either in c++ or python