Skip to content

Conversation

darshkantaria
Copy link

This PR adds a C++ solution for LeetCode Problem #337 - House Robber III

  • Approach: Dynamic Programming (Tree DP) using Post-order DFS

  • Each node computes two states:

    1. Rob this node → cannot rob its children
    2. Skip this node → free to rob or skip children
  • Time Complexity: O(n), where n = number of nodes

  • Space Complexity: O(h), where h = height of the tree

The code includes detailed inline comments and explanation of the approach,
making it easy to understand and reusable for similar tree DP problems.

Optional test case is included but commented out for safe submission.

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