Skip to content

Backtracking-3 Done#1075

Open
vaishnavi2231 wants to merge 1 commit intosuper30admin:masterfrom
vaishnavi2231:master
Open

Backtracking-3 Done#1075
vaishnavi2231 wants to merge 1 commit intosuper30admin:masterfrom
vaishnavi2231:master

Conversation

@vaishnavi2231
Copy link

No description provided.

@super30admin
Copy link
Owner

Strengths:

  • The N-Queens solution is correct and follows the standard backtracking approach.
  • The code is well-organized with helper functions for clarity.
  • The isSafe function correctly checks the column and both diagonals.

Areas for Improvement:

  • In the helper function for N-Queens, the parameter 'j' is unnecessary since it is not used. You can remove it and define j only in the inner loop.
  • Consider using a list of strings or a 1D array to represent the board to save space, but for n up to 9, the current approach is acceptable.
  • For the Word Search solution (if you want to improve), you can avoid the base case for a 1x1 board by handling it within the DFS. The current special case might not be necessary because the DFS should handle it.

Overall, both solutions are well-written and efficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants