Hey everyone, I wanted to ask one thing that when I iterate through an array and comparing something like ar[i] and ar[i+1] and if I do this in my VSCode and iterating till i<n (which is obviously not possible) but it runs completely fine on my VSCode and doesn't give an error while running it on Codeforces generally the program goes into pretests passed condition and gets rejected in checking phase. Please help because this costed me a very easy problem in the contest.
In my opinion, it takes "garbage value" for arr[n] or arr[n+1] or further, and obviously, you don't want to make comparisons with garbage values. Online Judges will give you a "SEGMENTATION FAULT", or "heap-buffer-overflow" as you will be accessing a block of the array that is never assigned, so it's best to check the basic things twice like loop conditions before submitting the final verdict. Hope it helps
because n[i+1} is not defined yet make another for loop and try it