Top-down: If you're not feeling ready to write the optimized solution, write a brute-force solution for "Chaos in the Grid with Cats."
When using GitHub mode, paste your repository URL below and click Save URL to store it. The saved URL will be automatically included with every message you send until you choose to clear it. Learn more
Top-down: If you're not feeling ready to write the optimized solution, write a brute-force solution for "Chaos in the Grid with Cats."
function chaosInTheGridWithCats(grid) {
const rows = grid.length;
const cols = grid[0].length;
function helper(row, col) {
if (row < 0 || col < 0 || grid[row][col] === "C") {
return 0;
}
if (row === 0 && col === 0) {
return 1;
}
return helper(row - 1, col) + helper(row, col - 1);
}
return helper(rows - 1, cols - 1);
}
Hi! I'm LSBot. I can help you think through the selected exercise by giving you hints and guidance without revealing the solution. Your code from the editor will be automatically detected. Want to know more? Refer to the LSBot User Guide .
Submit your solution for LSBot review. Hi! I'm LSBot. Your code from the editor will be automatically detected. I'll review your solution and provide feedback to help you improve. Ask questions about your solution or request a comprehensive code review. Want to know more? Refer to the LSBot User Guide .