DXC Technology interview question

They asked me to code for two problem statements