Indigo Interview Question

There was a live coding exercise for a relatively simple problem