There are two questions that I am trying to draw a comparison between:
Q1: Maximum Absolute Difference 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. Q2: Min Steps in Infinite Grid You are in an infinite 2D grid where you can move in any of the 8 directions : (x,y) to (x+1, y), (x - 1, y), (x, y+1), (x, y-1), (x-1, y-1), (x+1,y+1), (x-1,y+1), (x+1,y-1)
I was reading up about the Q2 and I came across this stackoverflow question. Here, the accepted answer reduces this question to
given a list of points in 2D space (x[i], y[i]), find two farthest points (with respect to Manhattan distance)
Reading up, I think both these questions are exactly the same except that Q1 is asking for Manhattan Distance in 1D and Q2 is asking for Manhattan Distance in 2D.
I am not very clear about this. Can someone please verify my observation?