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

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
icon
Related questions
Question

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≤ai≤109). 

 

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.

 

 

 

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Intermediate SQL concepts
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr