cermati interview question

what's the solution for the given problem