Skip to content

Commit

Permalink
updated files
Browse files Browse the repository at this point in the history
  • Loading branch information
joric committed May 4, 2020
1 parent 37d2562 commit aa4c750
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion programming/binary-search/search-for-a-range.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,16 @@ vector<int> Solution::searchRange(const vector<int> &A, int B) {
return sol;

}
```
```
## Another solution
```cpp
vector<int> Solution::searchRange(const vector<int> &A, int B) {
auto r = equal_range(A.begin(), A.end(), B);
if (r.first!=A.end() && *r.first!=B)
return {-1, -1};
return { r.first-A.begin(), r.second-A.begin()-1 };
}
```

0 comments on commit aa4c750

Please sign in to comment.