今天心情不好,就做一道

- class Solution {
- public:
- int countTarget(vector<int>& scores, int target) {
- return help(scores,target)-help(scores,target-1);
- }
- int help(vector<int>&scores,int target)
- {
- int left = 0;
- int right = scores.size()-1;
- while(left <= right)
- {
- int mid = (left+right)/2;
- if(scores[mid] <= target) left=mid+1;
- else right = mid-1;
- }
- return left;
- }
- };