【LeetCode 0051】【剪枝】N皇后

  1. N-Queens

The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.

Given an integer n, return all distinct solutions to the n-queens puzzle. You may return the answer in any order.

Each solution contains a distinct board configuration of the n-queens’ placement, where 'Q' and '.' both indicate a queen and an empty space, respectively.

Example 1:

**Input:** n = 4
**Output:** [[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]
**Explanation:** There exist two distinct solutions to the 4-queens puzzle as shown above

Example 2:

**Input:** n = 1
**Output:** [["Q"]]

Constraints:

  • 1 <= n <= 9
JavaScript Solution

相关推荐

  1. leecode N皇后

    2024-07-16 05:02:01       33 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-16 05:02:01       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-16 05:02:01       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-16 05:02:01       57 阅读
  4. Python语言-面向对象

    2024-07-16 05:02:01       68 阅读

热门阅读

  1. 跨域的解决方案

    2024-07-16 05:02:01       27 阅读
  2. Jenkins教程-20-常用插件-Parameterized Trigger

    2024-07-16 05:02:01       22 阅读
  3. Go中的defer看似很简单,实则一点都不难

    2024-07-16 05:02:01       22 阅读
  4. 训练营第十三天 | 二叉树的递归遍历、层序遍历

    2024-07-16 05:02:01       24 阅读
  5. MySQL-字符集(charset)和校对规则(collation)

    2024-07-16 05:02:01       26 阅读
  6. 掌握Eureka:打造高效服务配置中心集成

    2024-07-16 05:02:01       27 阅读
  7. Docker的基本认识和常见命令以及场景介绍

    2024-07-16 05:02:01       21 阅读
  8. Spark和Hadoop作业之间的区别

    2024-07-16 05:02:01       28 阅读