Company: VinnovateLabz_9thjuly
Difficulty: easy
Array Challenge A sequence of numbers is rising at some step when the next value is larger than the current one, and falling when the next value is smaller. Values that repeat do not move the sequence in either direction, so a run of equal values leaves the current trend untouched. Given an array arr , report the index at which the array stops rising and begins falling , or stops falling and begins rising . If the array only ever rises, or only ever falls, report -1 . Indexing starts at 0 . If the array turns more than once, report only the first turning point. Input Format The first line contains a single integer n , the number of elements. The second line contains n space-separated integers arr[0] ... arr[n-1] . Output Format Print a single integer — the index of the first turning point, or -1 if the array never changes direction. Constraints 3 <= n <= 15000 -10^9 <= arr[i] <= 10^9 Examples Example 1 Input: 7 1 2 4 6 4 3 1 Output: 3 Explanation: the values rise up to 6 at