Skip to content

feat: implement HouseRobbing DP solution#22

Merged
bushidocodes merged 1 commit into
masterfrom
feat/house-robbing
Jun 12, 2026
Merged

feat: implement HouseRobbing DP solution#22
bushidocodes merged 1 commit into
masterfrom
feat/house-robbing

Conversation

@bushidocodes

Copy link
Copy Markdown
Owner

Summary

  • Adds HouseRobbing, a final static utility class in edu.gwu.csci6212, implementing the circular house-robber DP problem
  • Reduces the circular problem to two linear subproblems (exclude last house / exclude first house), each solved with the standard dp[i] = max(dp[i-1], dp[i-2] + houses[i]) recurrence
  • Validates input (null, empty, negative values) with IllegalArgumentException, matching the style of CoinPickingGame and MinimumStepsChessKnight

Test plan

  • Rejects null array
  • Rejects empty array
  • Rejects negative house value
  • Single house returns its value
  • Two houses returns the larger
  • Two identical houses returns that value
  • Assignment example 1: [2,3,2]3
  • Assignment example 2: [1,2,3,1]4
  • Greedy-fail case: [6,1,9,1,6]15 (naive every-other greedy would wrongly claim 6+9+6=21, violating the circular adjacency)
  • All-zeroes array returns 0
  • Larger circular case: [2,7,9,3,1]11

🤖 Generated with Claude Code

Adds circular house robber as a static utility class using the
two-subproblem DP reduction, with input validation and thorough tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bushidocodes bushidocodes merged commit 1656199 into master Jun 12, 2026
1 check passed
@bushidocodes bushidocodes deleted the feat/house-robbing branch June 12, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant