Skip to content

3065. Minimum Operations to Exceed Threshold Value I 👍

  • Time: $O(n)$
  • Space: $O(1)$
1
2
3
4
5
6
class Solution {
 public:
  int minOperations(vector<int>& nums, int k) {
    return ranges::count_if(nums, [k](int num) { return num < k; });
  }
};
1
2
3
4
5
class Solution {
  public int minOperations(int[] nums, int k) {
    return (int) Arrays.stream(nums).filter(num -> num < k).count();
  }
}
1
2
3
class Solution:
  def minOperations(self, nums: list[int], k: int) -> int:
    return sum(num < k for num in nums)