Skip to content

"Backtracking-3 done"#1079

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

"Backtracking-3 done"#1079
Sahithipsl470 wants to merge 1 commit intosuper30admin:masterfrom
Sahithipsl470:master

Conversation

@Sahithipsl470
Copy link

No description provided.

@super30admin
Copy link
Owner

N-Queens (Problem-1.java)

  1. The time complexity comment states O(N!) but should note that the isValid check adds O(n) per call, making overall O(n * n!).
  2. The space complexity comment mentions O(N) but ignores the board size O(n^2), which is significant.
  3. The canPut method uses three separate loops for checks, which is efficient. However, the variable names could be more descriptive (e.g., 'row' instead of 'r').
  4. The changeBoard method is clear but could be optimized by pre-allocating strings or using arrays for faster construction.

VERDICT: PASS


Word Search (Problem-1.py)

It appears you have submitted a solution for the N-Queens problem instead of the Word Search problem. Please review the problem statement carefully. For the Word Search problem, you need to implement a backtracking DFS that searches for a word in a grid by moving to adjacent cells (up, down, left, right) and backtracking when the path does not lead to the solution.

Here are some tips for the Word Search problem:

  1. You should iterate over each cell in the grid as a starting point.
  2. Use a DFS function that checks if the current cell matches the next character in the word.
  3. Mark the current cell as visited (e.g., by changing it to a special character) to avoid reuse, and then backtrack by restoring the original value after the DFS.
  4. Consider the constraints: the grid is small (up to 6x6) and the word length is up to 15, so backtracking is feasible.

Please ensure you are solving the correct problem. If you have any questions about the Word Search problem, feel free to ask.

VERDICT: NEEDS_IMPROVEMENT

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