DXC Technology Interview Question

They asked me to code for two problem statements