Created
March 23, 2021 11:22
-
-
Save rohanjai777/78a7af461030de530c9de54dfc9757db to your computer and use it in GitHub Desktop.
Min Steps in Infinite Grid InterviewBit Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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