DXC Technology interview question

Solve a coding problem