Skip to content

Instantly share code, notes, and snippets.

@rohanjai777
Created March 23, 2021 11:22
Show Gist options
  • Save rohanjai777/78a7af461030de530c9de54dfc9757db to your computer and use it in GitHub Desktop.
Save rohanjai777/78a7af461030de530c9de54dfc9757db to your computer and use it in GitHub Desktop.
Min Steps in Infinite Grid InterviewBit Solution
public class Solution {
public int coverPoints(int[] A, int[] B) {
int sum = 0;
for(int i=1;i<A.length;i++){
int v1 = Math.abs(A[i] - A[i-1]);
int v2 = Math.abs(B[i] - B[i-1]);
int max = Math.max(v1,v2);
sum+=max;
}
return sum;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment