MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / isValid

Method isValid

Java/LeetCodeN-Queens.java:35–51  ·  view source on GitHub ↗
(List<String> list, int row, int column, int n)

Source from the content-addressed store, hash-verified

33 }
34 }
35 public static boolean isValid(List<String> list, int row, int column, int n){
36 if(row > 0){
37 String cmp = list.get(row - 1);
38 for(int i = 0; i < row; i++)
39 if(list.get(i).charAt(column) == 'Q') return false;
40 int tempRow = row;
41 int tempCol = column;
42 while(--tempRow >= 0 && --tempCol >= 0){
43 if(list.get(tempRow).charAt(tempCol) == 'Q') return false;
44 }
45 tempRow = row;
46 tempCol = column;
47 while(--tempRow >= 0 && ++tempCol <= n-1)
48 if(list.get(tempRow).charAt(tempCol) == 'Q') return false;
49 }
50 return true;
51 }
52 private static String createQueen(int n, int index){
53 StringBuilder sb = new StringBuilder();
54 int i = 0;

Callers 1

backtraceMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected