Skip to content

Commit

Permalink
3375
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangshanmeta committed Jan 21, 2025
1 parent 7d01831 commit 8eefb44
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution {
public int minOperations(int[] nums, int k) {
int count = (int)Arrays.stream(nums).distinct().count();

int min = nums[0];
for(int n:nums){
min = Math.min(min,n);
}
if(k>min){
return -1;
}
return count-( k<min?0:1);
}
}

0 comments on commit 8eefb44

Please sign in to comment.