Cpp, Cplusplus, Programming, Software Development, Interview Questions.
(pos.col + dir.col < 0) return false; if (pos.col + dir.col >= std::ssize(grid[pos.row])) return false; return true; }; // Helper to check if a space is empty auto is_empty = [&grid](const Pos& pos, const Dir& dir) { return grid[pos.row+dir.row][pos.col+dir.col] == 0; }; // Helper to check if a