Accenture Interview Question

Light on or off problem from leetcode.