cs: add «3375. Minimum Operations to Make Array Values Equal to K»

URL:	https://leetcode.com/problems/minimum-operations-to-make-array-values-equal-to-k/
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2025-04-09 09:45:46 +02:00
parent e95583b334
commit 9754709bd4
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

View file

@ -0,0 +1,16 @@
public class Solution {
public int MinOperations(int[] nums, int k) {
var toUse = new HashSet<int>();
foreach (var x in nums) {
if (x < k) {
// can't use any number of operations
return -1;
} else if (x > k) {
// gotta use it at least once
toUse.Add(x);
}
}
return toUse.Count;
}
}