Please check for error

here is my code:


Please check why it fails test case 1 and 2

@Garvit012, you have to take absolute value of difference

maxdiff+=abs(arr[n-i-1]-arr[i]); 
mindiff+=abs(arr[i]-arr[i-1]);

corrected code :-

@O17LPOLA020023 thanks for your help it works now but I can’t understand the need of using abs function since the arr is sorted, therefore ,
arr[i] > arr[i-1]

yes , your code is correct try to submit your previous code now

now the previous code is working too idk how😂

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.