private static boolean isSafe(boolean [][]chess, int r, int c) {
    // rows on left
    for(int i = 0; i < c; i++) {
      if(chess[r][i]) {
        return false;
      }
    }
    // diagonally left above
    for(int i = r, j = c; i >= 0 && j >= 0; i--, j--) {
      if(chess[i][j]) {
        return false;
      }
    }
    // diagonally left below
    for(int i = r, j = c; i < chess.length && j >= 0; i++, j--) {
      if(chess[i][j]) {
        return false;
      }
    }
    return true;
  }