完成每日一题:超过阈值的最少操作数 I
This commit is contained in:
parent
828069bf1a
commit
b7d0c2caf8
25
minOperations.cpp
Normal file
25
minOperations.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class Solution {
|
||||||
|
public:
|
||||||
|
int minOperations(vector<int>& nums, int k) {
|
||||||
|
int counter = 0;
|
||||||
|
for(auto i:nums){
|
||||||
|
if(i < k){
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
Solution solution;
|
||||||
|
vector<int> nums = {2,11,10,1,3};
|
||||||
|
int k = 10;
|
||||||
|
cout << solution.minOperations(nums, k) << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user