Accenture Interview Question

It was hard to solve