Accenture interview question

Light on or off problem from leetcode.