Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

nums =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Circular houses => cannot take both first and last.

Approach

Compute max of two linear robberies:

  1. Rob houses [0..n-2]
  2. Rob houses [1..n-1] Use House Robber I DP for each.

Why it works

Any optimal set either includes the first (thus excludes last) or excludes first (thus may include last).

Code
Loading...
Complexity
Time: O(n)
Space: O(1)
Solution
Updated: 2026-02-23

Idea

Circular houses => cannot take both first and last.

Approach

Compute max of two linear robberies:

  1. Rob houses [0..n-2]
  2. Rob houses [1..n-1] Use House Robber I DP for each.

Why it works

Any optimal set either includes the first (thus excludes last) or excludes first (thus may include last).

Code
Loading...
Complexity
Time: O(n)
Space: O(1)