Accenture Interview Question

A medium array question - usual leetcode stuff