213. House Robber II

All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one.

so it means, we can define two cases with House Rober 1

  1. rob first house

  2. rob last house

solution:

dpFunction is the solution of 198. House Robber

time: O(n)

space: O(n)

----

time: O(n)

space:O(1)

use this one!

Last updated

Was this helpful?