MCPcopy Create free account
hub / github.com/apna-college/Alpha / MinAbsoluteDiff

Class MinAbsoluteDiff

15_Greedy/MinAbsoluteDiff.java:2–17  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1import java.util.Arrays;
2public class MinAbsoluteDiff {
3 public static void main(String args[]) {
4 int A[] = {4, 1, 8, 7};
5 int B[] = {2, 3, 6, 5};
6
7 Arrays.sort(A);
8 Arrays.sort(B);
9
10 int sum = 0;
11 for(int i=0; i<A.length; i++) {
12 sum += Math.abs(A[i]-B[i]);
13 }
14
15 System.out.println("min absolute diff of pairs = " + sum);
16 }
17}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…