House Robber | LeetCode 198 | Google Coding Interview Tutorial
Vložit
- čas přidán 26. 07. 2024
- House Robber solution: LeetCode 198
Code and written explanation: terriblewhiteboard.com/house-...
Link to problem: leetcode.com/problems/house-r...
Buy Me a Coffee: www.buymeacoffee.com/terrible...
AFFILIATE LINKS
If you're interested in learning algorithms, these are great resources.
💻 40% off Tech Interview Pro: techinterviewpro.com/terriblew...
⌨️ 20% off CoderPro: coderpro.com/terriblewhiteboard
💲 All coupons and discounts 💲
terriblewhiteboard.com/coupon...
House Robber | LeetCode 198 | Google Coding Interview
#houserobber #leetcode #algorithms #terriblewhiteboard #codinginterview
Click the time stamp to jump to different parts of the video.
00:00 Title
00:07 Problem readout
01:03 Whiteboard solution
04:09 Coding solution
09:21 Result and outro
If there are any videos you'd like me to make or if you have any ideas on how to optimize this solution, let me know!
please make all variations of buying and selling stocks please !!
can you make the video for Sort List ? #148 with the "BOTTOM UP MERGE SORT" solution? There are videos explaining this question. However, no one explain the bottom up merge sort with O(1) space complexity.
You are very gifted at teaching. I can't thank you enough.
Thanks!
Brilliant! Whiteboard solution part was enough for me to get the logic. Thanks !
Awesome!
You explain very nicely. Please make a tutorial series on Dynamic Programming! Thanks for your efforts! :-)
Thanks!
Your videos are great. Just a suggestion, it would be great to add Big O analysis and optimisations (e.g. don't need to store full dp array, can reduce space complexity from O(n) to O(1) by storing 2 variables instead.)
Love the way you explain things. Keep it up you are doing a great job and hope your channel grows.
Thank you!
I watched a bunch of videos on this problem and studied the discussion section on leet code. I was very confused until just now. You're a great teacher man. Thank you for your help.
thank you so much
You're welcome!
Great Explanation! Can't thank you enough for this!!
Thanks! Glad to help!
that was a wonderful explaination
totally got the logic
Thanks!
great job !
Thanks!
Nicely explained ! Thanks
You're welcome!
This is the best explanation for this problem on CZcams. Thanks.
very clear explanation, thank you!
Thanks!
very well explained. Thanks for spending time for making this video
Thanks!
Excellent explanation. I spent nearly 2 hours trying to find an ultimate solution for every case but I gave up... Thanks to your explanation now I completely have a grasp of that problem. You're a brilliant teacher
Thanks!
Very interesting 👍
Thanks!
You are the best man!!! I struggled so hard to understand but you've made it so cleart for me, thank you so much!! I implemented what you explained into my own code and it worked first time !!!
Thanks! Glad to hear it!
The best explanation so far, thank you for making this video!
very intuitive solution that helps a lot with other dp problems, thank you!
You're welcome!
Is this the optimal solution? Space complexity could be reduced by only memo-izing the last max values (instead of memo-izing all of them)
You're right, my space complexity shot up to 90% since now it's O(1) space. Here's my code:
var rob = function(nums) {
if(!nums || nums.length === 0) return 0;
if(nums.length === 1) return nums[0]
let prevMax = nums[0], currMax = Math.max(nums[0], nums[1]), tempMax
for(let i = 2; i < nums.length; i++){
tempMax = Math.max(prevMax + nums[i], currMax)
prevMax = currMax
currMax = tempMax
}
return currMax
};
Thank you for explaining things so well
You're welcome!
great explanation. Thank you
Thanks!
Very good explanation sir
thanks
didn't pay much attention and thought you coded in java :)) , anyways very good teaching , I finally understood this 1d dp
What app are you using to draw on these videos? It's like a whiteboard!
It’s just the standard Notes app on the iPad.
@@TerribleWhiteboard What hardware is that? So, you just connect your IPad and write on screen? How was Mac able to split the drawing from IPad input and typing from Keyboard input at the same time?
I use the Apple Pencil to draw and a separate bluetooth external keyboard to type. They're both connected at the same time.
wouldnt you get an out of bounds exception at the last number in the array loop?
Your voice feels like you are sad or cryring 😅
The saddest.
id have to disagree with this comment. its pretty chill.
gg
Thanks!