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

Method findSquareWithSize

java/Chapter 18/Question18_11/Question.java:6–19  ·  view source on GitHub ↗
(int[][] matrix, int squareSize)

Source from the content-addressed store, hash-verified

4
5public class Question {
6 public static Subsquare findSquareWithSize(int[][] matrix, int squareSize) {
7 // On an edge of length N, there are (N - sz + 1) squares of length sz.
8 int count = matrix.length - squareSize + 1;
9
10 // Iterate through all squares with side length square_size.
11 for (int row = 0; row < count; row++) {
12 for (int col = 0; col < count; col++) {
13 if (isSquare(matrix, row, col, squareSize)) {
14 return new Subsquare(row, col, squareSize);
15 }
16 }
17 }
18 return null;
19 }
20
21 public static Subsquare findSquare(int[][] matrix){
22 assert(matrix.length > 0);

Callers 1

findSquareMethod · 0.95

Calls 1

isSquareMethod · 0.95

Tested by

no test coverage detected