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

Method isSquare

java/Chapter 18/Question18_11/QuestionEff.java:40–57  ·  view source on GitHub ↗
(SquareCell[][] matrix, int row, int col, int size)

Source from the content-addressed store, hash-verified

38 }
39
40 private static boolean isSquare(SquareCell[][] matrix, int row, int col, int size) {
41 SquareCell topLeft = matrix[row][col];
42 SquareCell topRight = matrix[row][col + size - 1];
43 SquareCell bottomRight = matrix[row + size - 1][col];
44 if (topLeft.zerosRight < size) { // Check top edge
45 return false;
46 }
47 if (topLeft.zerosBelow < size) { // Check left edge
48 return false;
49 }
50 if (topRight.zerosBelow < size) { // Check right edge
51 return false;
52 }
53 if (bottomRight.zerosRight < size) { // Check bottom edge
54 return false;
55 }
56 return true;
57 }
58
59 public static SquareCell[][] processSquare(int[][] matrix) {
60 SquareCell[][] processed = new SquareCell[matrix.length][matrix.length];

Callers 1

findSquareWithSizeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected