You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Proper index conversion between 0-indexed array and 1-indexed labels
Areas for Improvement:
Consider adding comments explaining the indegree concept for better readability
Could add an early check: if trust is empty and n == 1, return 1 directly (though current solution handles this correctly anyway)
The solution is functionally equivalent to the reference solution and demonstrates solid understanding of the problem.
VERDICT: PASS
Ball in the Maze (Problem_2.py)
Strengths:
Clean BFS implementation with good variable naming
Correct rolling ball logic implementation
Proper use of deque for queue operations
Good comments and code organization
Areas for Improvement:
Critical Bug: You mark cells as visited (maze[cr][cc] = 2) before rolling in all directions. This can cause issues when a ball rolls and returns to its starting position - that position won't be re-added to the queue even though it might be needed for other paths. Move the marking to after you've determined the ball stops at a new position.
Code Duplication: The rolling logic is repeated. Consider extracting it into a helper function like roll_ball(cr, cc, direction).
Edge Case Handling: The solution handles boundaries correctly during rolling, but the logic could be clearer with early returns or helper functions.
Suggested Fix:
ifmaze[nr][nc] !=2:
q.append([nr, nc])
maze[nr][nc] =2# Mark when adding to queue, not when popping
VERDICT: NEEDS_IMPROVEMENT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.