欢迎光临散文网 会员登陆 & 注册

前端早早聊大会2022-低代码专场

2022-10-11 15:26 作者:芢依稀久忆0  | 我要投稿

private boolean isValid(List<String> solutionOfXMinus1, int i, int x) {        for (int rowIndex = 0; rowIndex < solutionOfXMinus1.size(); rowIndex++) {            // 例如: "...Q"            String row = solutionOfXMinus1.get(rowIndex);            int queenRowIndex = rowIndex + 1;            int queenColIndex = row.indexOf("Q") + 1;            // 在同一列            if (queenColIndex == i) {                return false;            }            // 在对角线            if (((queenRowIndex + queenColIndex) == (x + i)) || ((queenRowIndex - queenColIndex) == (x - i))) {                return false;            }        }        return true;    }



前端早早聊大会2022-低代码专场的评论 (共 条)

分享到微博请遵守国家法律