Загрузка страницы

GOOGLE CODING INTERVIEW QUESTION - HOUSE ROBBER (LeetCode)

This is one of Google's most commonly asked interview questions according to LeetCode (2019)! House Robber coding solution. If you give me 5 minutes you'll thank me if this appears during your interview! Coding Interviews House Robber (LeetCode) question and explanation.

DISCORD CHANNEL
----------------------------------------------------------------------------------------------------------------
To join the Discord channel use the following link and join the "Member" tier: https://www.patreon.com/KevinNaughtonJr
In this Discord channel, you will be able to...
1. Ask me questions directly (as well as other members)
2. Ask about and discuss previous interview experiences
3. Find mock interview partners
4. Share helpful videos for interview preparation, and more!

This question is commonly asked by the following companies: Google, Amazon, Quora, and Adobe.

Link to problem: https://leetcode.com/problems/house-robber/

Intuition behind solution: Solve the problem for simpler cases to help us solve the larger problem at hand (this is the idea of bottom-up processing). Create a dp array where dp[i] will represent the max amount of money we can rob up to and including the current house. First fill the simple cases, or base cases, of the dp array like dp[0] = nums[0] (the most amount of money we can rob up to the first house is however much money is in the first house, dp[1] = max of num[0] and nums[1] (we can't rob both because of the alarm systems so rob whichever house has more money). Then iterate through the rest of the dp array populating dp[i] at every iteration using the follow logic...dp[i] = max of robbing the current house and however much money we had 2 houses before, or simply continue on with the max amount of money we had robbed up to the previous house. Once you have populated the dp array simply return the last entry which represents the max amount of money you can rob from all the houses without triggering the alarm system.

SOCIAL
----------------------------------------------------------------------------------------------------------------
Support me on Patreon: https://www.patreon.com/KevinNaughtonJr
Follow me on Twitter: https://twitter.com/KevinNaughtonJr
Follow me on Instagram: https://www.instagram.com/kevinnaughtonjr/
Follow me on GitHub: https://github.com/kdn251

MUSIC
----------------------------------------------------------------------------------------------------------------
Blushes by Dj Quads
https://soundcloud.com/aka-dj-quads/blushes

#coding #interviews #softwareengineering

Видео GOOGLE CODING INTERVIEW QUESTION - HOUSE ROBBER (LeetCode) канала Kevin Naughton Jr.
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
28 марта 2019 г. 6:30:02
00:07:32
Яндекс.Метрика