title: Maximum Absolute Difference
body: <p><strong>You are given an array of N integers, A1, A2 ,…, AN. Return maximum value of f(i, j) for all 1 ≤ i, j ≤ N.
  f(i, j) is defined as |A[i] - A[j]| + |i - j|, where |x| denotes absolute value of x.</strong></p>
  
  <blockquote>
    <p>For example,
        <code>A=[1, 3, -1]
        f(1, 1) = f(2, 2) = f(3, 3) = 0
        f(1, 2) = f(2, 1) = |1 - 3| + |1 - 2| = 3
        f(1, 3) = f(3, 1) = |1 - (-1)| + |1 - 3| = 4
        f(2, 3) = f(3, 2) = |3 - (-1)| + |2 - 3| = 5
        So, we return 5.</code><br>
    <a href="https://www.interviewbit.com/problems/maximum-absolute-difference/" rel="nofollow noreferrer">https://www.interviewbit.com/problems/maximum-absolute-difference/</a></p>
  </blockquote>
  
  <pre><code>int Solution::maxArr(vector&lt;int&gt; &amp;A) {
  
      int size = A.size();
      int max_diff = 0;
      for(int i = 0 ; i &lt; size ; i++)
      {
          for(int j = i ; j &lt; size ; j++)
          {
              int diff = abs(A[i]-A[j])+abs(i-j);
              max_diff = max(max_diff,diff);
          }
  
      }
      return max_diff;
  }
  </code></pre>
  
  <p>There are many question on stack overflow with same title but none of them is properly answered.
  Above code shows time limit exceeded.Also i am not getting the question properly.I ve come up with this sol with a little understanding and equation suggested in question.It passes the sample test cases but for the rest of cases its time limit exceeded.
  Any help in understanding the ques and where i am getting wrong in my solution will be appreciated.ed.</p>