← All problemsSign in

Weird Subarrays

CodeChefRating 1739Open on judge ↗

An array $A$ is called *weird* if it can be sorted in non-decreasing order by applying the given operation any number of times: - Select any index $i$ $(1 \le i \le |A|)$ and set $A_i := -A_i$. For example: $A = [2, 1, 3]$ is *weird* since after applying the operation at $i = 1$, $A$ becomes $[-2, 1, 3]$ which is sorted. JJ has a permutation $P$ of length $N$. He wants to find the number of suba

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start