Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- vector<int> arr = {1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 5, 8, 9};
- int n;
- cin >> n;
- int indexOne = lower_bound(arr.begin(), arr.end(), n) - arr.begin();
- int indexTwo = upper_bound(arr.begin(), arr.end(), n) - arr.begin();
- int result = indexTwo - indexOne;
- cout << n << " occurs " << result << " time" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement