20241024 finished.

This commit is contained in:
2024-10-24 09:08:13 +08:00
parent 3102da99a8
commit bce8de1c85
266 changed files with 2321 additions and 2014 deletions

View File

@@ -9,17 +9,17 @@
* Input: n = 4
* Output: 2
* Explanation: There are two distinct solutions to the 4-queens puzzle as shown.
*
*
* <strong class="example">Example 2:
*
*
* Input: n = 1
* Output: 1
*
*
*
* Constraints:
*
*
* 1 <= n <= 9
*
*
*/
pub struct Solution {}
@@ -47,11 +47,11 @@ impl Solution {
while let Some((x, y, flag)) = stack.pop_back() {
if flag {
x_occupied[y] = false;
y_occupied[n - 1 + x - y] = false;
y_occupied[n - 1 + x - y] = false;
z_occupied[x + y] = false;
} else {
x_occupied[y] = true;
y_occupied[n - 1 + x - y] = true;
y_occupied[n - 1 + x - y] = true;
z_occupied[x + y] = true;
stack.push_back((x, y, true));