Tom & Jerry
Practice
3.9 (12 votes)
Recursion
Dynamic programming
Easy Medium
Backtracking
Problem
19% Success 3117 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Tom and Jerry are wonderful characters. They are always running and make us laugh.

Right now, they are in a grid of houses and Jerry is running away from Tom. The grid of houses is represented as 0 and 1, where 0 means that Jerry can enter the house, and 1 means Jerry can't. Jerry can only move horizontally or vertically. Also, Jerry doesn't enter the same house more than once.

Jerry started running from the house at (\(1,1\)) which is the top-left house in the grid and have to reach (\(N,N\)) which the bottom-right house in the grid. You have find the number of ways in which Jerry can reach the destination house where he can be safe.

Input Format

First line is an integer N ( \(N \le 100\)), which is the size of the grid. N lines follow, each containing N space separated numbers which are either '0' or '1'.

Output format

Print a single line showing the number of ways in which Jerry can reach from (\(1,1\)) to (\(N,N\)).

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
No similar problems found