Google | Onsite Interview | House Robber 2D version
Anonymous User
2322

Given a mxn matrix int[][] nums, representing the money in each house. When you rob a house (i, j), you cannot rob the 8 houses nearby. Find the maximum amount of money you can rob.

For example:

House money:
example:
10 20 10
20 30 20
10 20 10

the best way is

1 0 1
0 0 0
1 0 1
which is 40

or

0 1 0
0 0 0
0 1 0
which is also 40

or
0 1 0
0 0 0
1 0 1
which is also 40

Comments (5)