MCPcopy Index your code
hub / github.com/careercup/ctci / main

Method main

java/Chapter 11/Question11_6/QuestionB.java:59–80  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

57 }
58
59 public static void main(String[] args) {
60 int[][] matrix = {{15, 30, 50, 70, 73},
61 {35, 40, 100, 102, 120},
62 {36, 42, 105, 110, 125},
63 {46, 51, 106, 111, 130},
64 {48, 55, 109, 140, 150}};
65
66 AssortedMethods.printMatrix(matrix);
67 int m = matrix.length;
68 int n = matrix[0].length;
69
70 int count = 0;
71 int littleOverTheMax = matrix[m - 1][n - 1] + 10;
72 for (int i = 0; i < littleOverTheMax; i++) {
73 Coordinate c = findElement(matrix, i);
74 if (c != null) {
75 System.out.println(i + ": (" + c.row + ", " + c.column + ")");
76 count++;
77 }
78 }
79 System.out.println("Found " + count + " unique elements.");
80 }
81
82}

Callers

nothing calls this directly

Calls 2

printMatrixMethod · 0.95
findElementMethod · 0.95

Tested by

no test coverage detected