hanchenchen
8/11/2019 - 11:20 AM

bound()

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	//                  0  1  2  3  4  5  6  7  8  9 
	vector<int> arr = { 1, 2, 2, 3, 3, 3, 4, 4, 4, 4 };
	cout << lower_bound(arr.begin(), arr.end(), 3) - arr.begin() << endl;	// 3
	cout << upper_bound(arr.begin(), arr.end(), 3) - arr.begin() << endl;	// 6
	return 0;
}