Skip to content

Instantly share code, notes, and snippets.

@mym0404
Created June 6, 2022 14:48
Show Gist options
  • Save mym0404/8fbf6867fc736e4686a080d0463cfae1 to your computer and use it in GitHub Desktop.
Save mym0404/8fbf6867fc736e4686a080d0463cfae1 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
vector<int> arr{1, 2, 3, 3, 5, 6, 6, 8, 9, 10};
int left = 0, right = arr.size() - 1, target = 8;
int answer = lower_bound(arr.begin(), arr.end(), target) - arr.begin();
cout << answer;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment