Leetcode Subarray From A Binary Switch With Relay