In this problem, we say that a vector with integer numbers @v[0..@@]@ is bi-increasing if , @v[0]@ @v[@@]@, and there exists an index between and such that:
@v[0]@ @v[@@]@ @v[@@]@,
@v[@@]@ @v[@@]@ @v[@@]@.
For instance, the vector @[12, 12, 15, 20, 1, 3, 3, 5, 9]@ is bi-increasing (with ).
Implement an efficient function
bool search(int x, const vector<int>& v);
such that, given an integer number @x@ and a bi-increasing vector @v@, returns if @x@ is in @v@ or not. You can use and implement auxiliary functions if you need them.
The vector @v@ is bi-increasing.
You only need to submit the required procedure; your main program will be ignored.