Skip to content

Commit 5cbcaff

Browse files
authoredApr 9, 2025··
Create 3375_Minimum_Operations_to_make_Array_values_Equal_to_k.java
1 parent bf3ac5b commit 5cbcaff

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Problem Number: 3375
2+
3+
// Minimum Operations to make Array values Equal to k.
4+
5+
class Solution {
6+
public int minOperations(int[] nums, int k) {
7+
Set<Integer> numsSet = Arrays.stream(nums).boxed().collect(Collectors.toSet());
8+
final int mn = Arrays.stream(nums).min().getAsInt();
9+
if (mn < k)
10+
return -1;
11+
if (mn > k)
12+
return numsSet.size();
13+
return numsSet.size() - 1;
14+
}
15+
}

0 commit comments

Comments
 (0)
Please sign in to comment.