educative.io

Query for edge case for peak of a mountain

While determining the peak of the mountian array if the peak is found out at last or first element then shouldn’t we return -1 indicating that the peak for that array can’t be found ?
The solution includes the condition for finding peak at last element into the solution but shouldn’t it be like this
if(mid == nums.length - 1 || mid == 0 ) return -1;

Hi Yogesh Edekar
Can you please specify the exact lesson where you’re facing this ambiguity so that we can help you out to clear your confusion.

Thank you!