Allow us to characterize the terrorizing worth of a succession as the amount of the number of slopes and the number of valleys in the arrangement. You can change precisely one integer in the succession to any number that you need, or let the grouping stay unaltered. What is the base terrorizing esteem that you can accomplish
Correct answer will be upvoted else Multiple Downvoted. Computer science.
Allow us to characterize the terrorizing worth of a succession as the amount of the number of slopes and the number of valleys in the arrangement. You can change precisely one integer in the succession to any number that you need, or let the grouping stay unaltered. What is the base terrorizing esteem that you can accomplish?
Input
The main line of the input contains a solitary integer t (1≤t≤10000) — the number of experiments. The portrayal of the experiments follows.
The main line of each experiment contains a solitary integer n (1≤n≤3⋅105).
The second line of each experiment contains n space-isolated integers a1, a2, ..., an (1≤
It is ensured that the amount of n over all experiments doesn't surpass 3⋅105.
Output
For each experiment, print a solitary integer — the base terrorizing esteem that you can accomplish.
Step by step
Solved in 4 steps with 1 images