Positive or Negative Subarrays
Consider an array $A$ having length $N$ such that $A_i = 2^{i-1}$ for all $1 \le i \le N$. You are given an integer array $B$ having length $N$ such that $B_i = +1$ or $B_i = -1$ for all $1 \le i \le N$. We create another array $C$ of length $N$ such that $C_i = B_i \cdot A_i$ - Let the number of subarrays of $C$ having sum **strictly** greater than $0$ be $P$ and - Let the number of subarrays
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start