Solving House Robber Problem 198 with Java Dynamic Programming

💡 Day 43 Solved "House Robber" Problem #198 using Java! Today I worked on a classic Dynamic Programming problem on LeetCode – House Robber 🏠💰 🔍 Problem: Find the maximum amount of money you can rob without robbing two adjacent houses. 🧠 Approach: At every step, we decide: ✔️ Rob current house → add value + profit from i-2 ✔️ Skip current house → take profit from i-1 We choose the maximum of these two options. 🚀 Optimization: Instead of using a DP array, I used two variables to reduce space complexity to O(1). ⏱ Time Complexity: O(n) 📦 Space Complexity: O(1) This problem is a great example of how dynamic programming simplifies complex decisions! #LeetCode #Java #DynamicProgramming #CodingJourney #ProblemSolving

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories