You are given an array of numbers and you have to return the count of subarrays whose elements and operations gives 0
Ex:
Input: arr = [8, 9, 1, 2]
output: 4
Explanations:
The subarrays which satisfy the consition are:
[8, 9, 1, 2], (8 & 9 & 1 & 2 = 0)
[8, 9, 1], (8 & 9 & 1 = 0)
[9, 1, 2], (9 & 1 & 2 = 0)
[1, 2] (1 & 2 = 0)
so return 4
I can think of O(n^2) solution
link to leetcode playground: https://leetcode.com/playground/fnVa5ttH
Is it possible to get a recursive solution with better complexity?