This post is all about the solution of the "Weird Subarrays" Starters 61 Division 3 (Rated) Problem Statement.

Building Race Codechef solution

Codechef 



Problem Statement:

An array AA is considered to be weird when it can be resolved in non-descending sequence any amount of times by performing the following procedure:

Pick any index ii (1 ile I ile |A|)(1iA) and set A i:= -A iA I :=A i.
As just an example: A = [2, 1, 3] A=[2,1,3] is strange then after applying the operation at I = 1i=1, AA becomes [-2, 1, 3][2, 1, 3], which would be sorted.

JJ does have a NN-length permutation PP. He needs to count the number of unusual PP sub - arrays. Could indeed you assist him?


Format of Input :

The very first line includes a single numeric value, TT, that also reflects the number of tests. Then come the testing process.
Evey test case begins with a numeric NN — the size of the permutation PP.
Evey test case's second sentence contains NN space-separated integer value P 1, P 2, dots, P NP 1,P 2,...,P N symbolising the permutation PP.


Format of the Output :

Output the number of unusual PP sub - arrays on a new product for every testing phase.


Also Check this out:-

Odd Sum Pair Starters 61 Division 3 (Rated) Problem Solution Click Here
Minimise LCS Starters 61 Division 3 (Rated) Problem Solution Click Here
Red Blue Flowers Starters 61 Division 3 (Rated) Problem Solution Click Here

Also Read :- Top Programming Languages of 2022 Click Here

Solution of the Problem: Click Here