MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / pairSum

Method pairSum

Java/Array/PairSum.java:52–64  ·  view source on GitHub ↗
(int[] arr, int x)

Source from the content-addressed store, hash-verified

50public class PairSum {
51
52 public static int pairSum(int[] arr, int x) {
53 int count = 0;
54 for (int i = 0; i < arr.length; i++) {
55 for (int j = i + 1; j < arr.length; j++) {
56 int sum;
57 sum = arr[i] + arr[j];
58 if (sum == x) {
59 count += 1;
60 }
61 }
62 }
63 return count;
64 }
65
66 public static int[] takingInput() {
67 Scanner sc = new Scanner(System.in);

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected