Algorithm · IBM · Medium
For an integer array arr, determine how many contiguous subarrays meet both conditions below: Their size is at least 2. Beginning with the second value of the subarray, each element must be exactly one less than the value immediately before it: arr[i] = arr[i-1] - 1 In other words, count contiguous ranges that are arithmetic progressions with a difference of -1. Input Line 1 contains the integer n. Line 2 contains n space-separated integers representing arr. Output Print a…
Checking your access…