Given an array A of N integers and an integer K. You can perform the following operation any number of times on the given array :
In different operations, different value of x and i can be chosen.
Task
Your task is to count minimum number of operations required such that following conditions are met:
If the above conditions cannot be met after any number of operations, return -1.
Note:
Example
Assumptions:
Approach:
Note, there can be other possible selections of x and i, at each step but the minimum number of operations remains the same.
Function description
Complete the minUpdates function provided in the editor. This function takes the following 3 parameters and returns an integer.
Input Format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
Output Format
For each test case in a new line, print an integer denoting the minimum number of operations required or print -1, if the conditions cannot be met.
Constraints
\(1 \le T \le 10^2 \\ 1 \le N \le 10^5 \\ 1 \le A[i], K \le 10^9 \\ \text{Sum of N over all test cases doesn't exceed} \ 10^6 \)
Code snippets (also called starter code/boilerplate code)
This question has code snippets for C, CPP, Java, and Python.
First line denotes number of test cases T = 2.
For first test case:
Approach:
For second test case:
Approach: