Created
June 6, 2022 14:48
-
-
Save mym0404/8fbf6867fc736e4686a080d0463cfae1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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