MCPcopy
hub / github.com/careercup/ctci / placeQueens

Method placeQueens

java/Chapter 9/Question9_9/Question.java:35–46  ·  view source on GitHub ↗
(int row, Integer[] columns, ArrayList<Integer[]> results)

Source from the content-addressed store, hash-verified

33 }
34
35 public static void placeQueens(int row, Integer[] columns, ArrayList<Integer[]> results) {
36 if (row == GRID_SIZE) { // Found valid placement
37 results.add(columns.clone());
38 } else {
39 for (int col = 0; col < GRID_SIZE; col++) {
40 if (checkValid(columns, row, col)) {
41 columns[row] = col; // Place queen
42 placeQueens(row + 1, columns, results);
43 }
44 }
45 }
46 }
47
48 public static void clear(Integer[] columns) {
49 for (int i = 0; i < GRID_SIZE; i++) {

Callers 1

mainMethod · 0.95

Calls 3

checkValidMethod · 0.95
addMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected