House Robber III Problem
House Robber III Problem — ExecCode Hard DSA Practice
Solve the House Robber III problem on ExecCode. Free online hard DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
The thief cannot rob two directly-linked houses in a binary tree. Return the maximum amount of money the thief can rob. For House Robber III, focus on the exact input variables, return only the requested value, and preserve the required time complexity for the intended pattern.
Examples
Input root = [3, 2, 3, null, 3, null, 1]; Output 7
Constraints
1 ≤ nodes ≤ 10^4 0 ≤ Node.val ≤ 10^4
Practice House Robber III free on ExecCode. Browse DSA problems, topic map, and placement guides.