题解 | #数字在升序数组中出现的次数#
数字在升序数组中出现的次数
http://www.nowcoder.com/practice/70610bf967994b22bb1c26f9ae901fa2
public:
int GetNumberOfK(vector<int> data ,int k) {
int count=0;
int i;
if(data.size()==0){
return 0;
}
for(i=0;i<=data.size()-1;i++){
if(data[i]==k){
count+=1;
}
}
return count;
}
};