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

AMAZON CODING INTERVIEW QUESTION - ROTTING ORANGES

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

This is one of Amazon's most commonly asked interview questions according to LeetCode (2019)! rotting oranges coding solution. If you give me 10 minutes you'll thank me if this appears during your Amazon interview! Coding Interviews rotting oranges (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: Amazon and Flipkart

Link to problem: https://leetcode.com/problems/rotting-oranges/

Intuition behind solution: save the initial state of the board by creating two hash sets to store both fresh oranges and rotten oranges. Iterate through the board populating both hash sets. Initialize your "minutes" to 0 and initialize a 2d integer array to represent the 4 cardinal directions (up, down, left, and right). While you have fresh oranges attempt to "infect" additional oranges by checking all rotten oranges you have and see if they have neighboring fresh oranges. Any time that they do, add that newly rotten orange to your "infected" hash set. Once you've run through all your rotten oranges you have available, if no new oranges became rotten (i.e. the size of infected is 0) return -1. Otherwise, continue your BFS by setting rotten = infected and incrementing the number of minutes elapsed by 1. Once your loop terminates return minutes.

MUSIC
----------------------------------------------------------------------------------------------------------------
xo bored llif3 by young frontwood
https://soundcloud.com/youngfrontwood/xo-bored-lif3

#techinterviews #leetcode #amazoninterview

Видео AMAZON CODING INTERVIEW QUESTION - ROTTING ORANGES канала Kevin Naughton Jr.
Показать
Комментарии отсутствуют
Введите заголовок:

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

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

Зарегистрируйтесь или войдите с
Информация о видео
27 февраля 2020 г. 4:45:00
00:15:44
Яндекс.Метрика