Maximum value of difference of a pair of elements and their Index(Contest)
Maximum value of difference of a pair of elements and their Index MediumAccuracy: 40.21%
Problem Statement :
Given an array arr[] of N positive integers. Find maximum value of |arr[i] – arr[j]| + |i – j|, (0 <= i, j <= N – 1)
Example 1:
Example 2:
Your Task: You don't need to read input or print anything. Your task is to complete the function maxValue() which takes an Integer N and an array arr of size N as input and returns the maximum possoble value of |arr[i] – arr[j]| + |i – j|.
PreviousLongest subarray not having more than K distinct elements(Contest)NextMinimum adjacent difference in a circular array easy(Contest)
Last updated