
Let arr[] = [2, 2, 4, 3, 6]. So minimum number of subarrays required is 2 which is [2, 2, 4] and [3, 6].
The first line of input contains a single integer ‘T’, denoting the number of test cases.
The second line of each test case contains ‘N’, denoting the number of elements in the array.
The third line of each test case contains the array elements.
The first and only line of each test case contains an integer denoting the minimum number of subarrays.
You are not required to print the expected output; it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= N <= 10^4
0 <= arr[i] <= 10^5
Time limit: 1 sec
We are traversing over all possible subarrays and checking if the given conditions are satisfied.
If conditions in all the subarrays are satisfied and the number of subarrays created is minimized, then we return the number as our answer.
The steps are as follows:
We can place a start pointer at the beginning of the array and an end pointer at the end of the array. If Gcd(start, end) is greater than 1, then we return 1 as an answer else, we move the start pointer to the following index and check if it is possible to make such subarrays. The first and last elements of the original array will always be used. The first element will be used in the first split, and the last element will be used if there is a split at the end.
The steps are as follows:
Pair Product Div by K
Pair Product Div by K
Merge Two Sorted Arrays Without Extra Space
Merge Two Sorted Arrays Without Extra Space
Co-Prime
First Digit One
Special Digit Numbers