You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Initial attempt where I make each iteration by pass and reuse the existing array. Was inefficient I realized but the math worked. The process consisted of...
4
+
5
+
1. Turning arr into a prefix sum array
6
+
2. Replacing each index of arr with a tuple containing the prefix count of the number of items prior that had an odd or even prefix sum
7
+
3. Returning the number of odd prefix sums plus the number of odds times the number of evens (since those can be matched up to get a subarray).
8
+
9
+
## V1
10
+
11
+
Much improved version that insteads sums the cases during the odds and evens iteration rather than replacing the array values
12
+
13
+
## V2
14
+
15
+
Improved version off of V1 that removes the need for the first prefix sum pass as it does all calculations within a single pass.
0 commit comments