Virtusa Interview Question

example problem to be solved with coding