MCPcopy Create free account
hub / github.com/careercup/ctci / findSquare

Method findSquare

java/Chapter 18/Question18_11/QuestionEff.java:21–38  ·  view source on GitHub ↗
(int[][] matrix)

Source from the content-addressed store, hash-verified

19 }
20
21 public static Subsquare findSquare(int[][] matrix){
22 assert(matrix.length > 0);
23 for (int row = 0; row < matrix.length; row++){
24 assert(matrix[row].length == matrix.length);
25 }
26
27 SquareCell[][] processed = processSquare(matrix);
28
29 int N = matrix.length;
30
31 for (int i = N; i >= 1; i--) {
32 Subsquare square = findSquareWithSize(processed, i);
33 if (square != null) {
34 return square;
35 }
36 }
37 return null;
38 }
39
40 private static boolean isSquare(SquareCell[][] matrix, int row, int col, int size) {
41 SquareCell topLeft = matrix[row][col];

Callers 1

mainMethod · 0.95

Calls 2

processSquareMethod · 0.95
findSquareWithSizeMethod · 0.95

Tested by

no test coverage detected