Conversation
N-Queens (NQueens.java)Your approach to solving the N-Queens problem is on the right track, but there are a few critical errors to address:
After fixing these issues, your solution should work correctly. Keep up the good work in thinking through the backtracking approach! VERDICT: NEEDS_IMPROVEMENT Word Search (WordSearch.java)Your solution is on the right track but has a critical bug related to backtracking the visited state. Specifically, when your DFS function finds a path (returns true), it does not reset the visited state of the current cell. This leaves the visited array in an inconsistent state for subsequent searches from other starting points. To fix this, you must ensure that the current cell's visited state is reset even when returning true. However, note that if you are returning true because you found the word, you don't want to reset the visited state for the entire path? Actually, for the problem, we only need to find one occurrence. So if we find the word, we can return true immediately without resetting the visited array? But wait: the visited array is shared across all starting points. When we start a new search from a new cell, we need the visited array to be clean. Therefore, you should reset the visited state of the current cell VERDICT: NEEDS_IMPROVEMENT |
No description provided.