Hello @Vikaspal,
-
The only issue with the segment of code that you have shared is:
For i=n-1, i+1=n and n is not valid
Solution:
iterate from i=0 to n-2. -
It should be 1 2.
As the sequence mentioned in the question is:
A[i] <= A[i + 1] … <= A[k] >= A[k + 1] >= … A[j – 1] > = A[j] -
You can declare it anyways. It won’t make any computational difference in the program.