Inactive Tutor answered 03/01/22
I'm assuming we want the function to return true if mile is equal to the largest value in the array and false otherwise. I'm also going to assume that the heights array is not sorted and that it only contains non-negative values.
bool isPeak(const int height[], int arrSize, int mile) {
int peak = -1;
for (int i=0; i<arrSize; i++) {
peak = max(peak, height[i]);
}
return mile == peak;
}