剑指offer---数字在排序数组中出现的次数
class Solution { public: int GetNumberOfK(vector<int> data, int k) { int data_size = data.size(); int cishu = 0; for (int i = 0; i < data_size; ++i) { if (data[i] == k) { ++cishu; } } return cishu; } };
class Solution { public: int GetNumberOfK(vector<int> data, int k) { int data_size = data.size(); int cishu = 0; for (int i = 0; i < data_size; ++i) { if (data[i] == k) { ++cishu; } } return cishu; } };