class Solution:
results = [] # to store results, using only 1D. row = index, col = value
def solveQueens(self, n, results):
for row in range(0, n): # the row to place queen
positions = get_available_positions(results) # all possible places to place queen at this row
for col in positions:
The use of backtracking technique.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.