To solve this problem you have to complete the code that you will find at the end of the statement. You have to replace each ??? with an expression of code. Do not change anything else. Download from the website of the problem the file code.cc with the code to be completed (click on the corresponding button “.CPP”), edit it and submit it to the judge. We also provide you with a file main.cc to help you when testing your solution, which you must not submit to the judge.
In this problem, we say that a vector with n integer numbers v[0..n−1] is cool if n ≥ 2, v[0] < v[n−1], and there exists an index j between 0 and n−2 such that:
For instance, the vector [9, 5, 3, 3, 1, 20, 15, 12, 12] is cool (with j = 4).
Implement an efficient function
that returns the position of the last occurrence of x in a cool vector v. If x does not belong to v, return a -1.
Precondition
The vector v is cool.