博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[LeetCode]N-Queens II
阅读量:4149 次
发布时间:2019-05-25

本文共 955 字,大约阅读时间需要 3 分钟。

class Solution {//http://www.matrix67.com/blog/archives/266//need more practice, solve N-Queens by bit manipulationpublic:	int cnt,upper;	int totalNQueens(int n) {		// Start typing your C/C++ solution below		// DO NOT write int main() function		cnt = 0;		upper = (1<
>1); } } else ++cnt; }};

second time

class Solution {//always pay attention to do not change the parameters in current level by forwardingpublic:    void solveNQueensUtil(int n, int curRow, int upc, int ld, int rd, int& totalCnt)    {        if(curRow == n)        {            totalCnt++;            return;        }                for(int j = 0; j < n; ++j)        {            int curNum = 1<
>1, (rd|curNum)<<1, totalCnt); } } int totalNQueens(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function int totalCnt = 0; solveNQueensUtil(n, 0, 0, 0, 0, totalCnt); return totalCnt; }};

转载地址:http://umxti.baihongyu.com/

你可能感兴趣的文章
Ribbon 学习(二):Spring Cloud Ribbon 加载配置原理
查看>>
Ribbon 学习(三):RestTemplate 请求负载流程解析
查看>>
深入理解HashMap
查看>>
XML生成(一):DOM生成XML
查看>>
XML生成(三):JDOM生成
查看>>
Ubuntu Could not open lock file /var/lib/dpkg/lock - open (13:Permission denied)
查看>>
collect2: ld returned 1 exit status
查看>>
C#入门
查看>>
C#中ColorDialog需点两次确定才会退出的问题
查看>>
数据库
查看>>
nginx反代 499 502 bad gateway 和timeout
查看>>
linux虚拟机安装tar.gz版jdk步骤详解
查看>>
python实现100以内自然数之和,偶数之和
查看>>
去哪儿一面+平安科技二面+hr面+贝贝一面+二面产品面经
查看>>
pytorch
查看>>
pytorch(三)
查看>>
C++ 调用json
查看>>
动态库调动态库
查看>>
Kubernetes集群搭建之CNI-Flanneld部署篇
查看>>
k8s web终端连接工具
查看>>