#C8773. Smallest k Partitions
Smallest k Partitions
Smallest k Partitions
You are given an array of integers. Your task is to determine the smallest number \(k\) such that the array can be partitioned into \(k\) contiguous subarrays, where each subarray is either strictly increasing or strictly decreasing.
Details:
- An increasing subarray is a sequence where every element is greater than the previous one.
- A decreasing subarray is a sequence where every element is less than the previous one.
- If consecutive elements are equal, they are treated as a break in monotonicity, and the current trend is reset.
Your goal is to compute the minimum \(k\) following the above rules.
Example:
Input: 1 6 1 2 3 4 3 2</p>Output: 2
inputFormat
The first line contains an integer \(T\) denoting the number of test cases.
For each test case, the input consists of two lines:
- The first line contains an integer \(n\), the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the array.
outputFormat
For each test case, output the smallest number \(k\) on a new line, indicating the minimal number of contiguous subarrays required such that each is strictly increasing or strictly decreasing.
## sample1
1
10
1
</p>