eG Innovations Interview Question

Asked to give output of the coding exercise