CodeArray Interview Question

Explain about your code, its approach