RUVIDEO
Поделитесь видео 🙏

Amazon Coding Interview Question - Sum of Left Leaves (LeetCode)

Here is a step by step explanation of a tree based question asked at Amazon.

Check out my interview prep platform for learning the patterns!
? Interview Prep Platform: https://algoswithmichael.com

? Join the community Discord: https://discord.gg/aVWsAaaCtT
? Support me on Patreon: https://www.patreon.com/michaelmuinos
?Follow me on LinkedIn: https://www.linkedin.com/in/michael-muinos
?Follow me on Github: https://github.com/MichaelMuinos

In this video, I go over the problem “Sum of Left Leaves” where we must sum up all left child nodes that are leaves in a given binary tree. This is a problem asked at both Amazon and Expedia.

A leaf is a node that does not have a left or right child connected to it, thus the premise behind solving this problem is every node we visit we must check the left child to see if it is null or not. If it is not null, we determine if it is a leaf. Determining if the node is a leaf or not can be offloaded to a helper function. If it is a leaf, then we add the value of the node to a sum variable which will eventually be returned from our function as the final result.

This problem can be solved recursively or iteratively. In the iterative approach, you may use a stack or a queue to solve the problem, the logic will be the same. I go over the queue solution, but it is up to you how you want to implement the iterative approach.

The time and space complexity for both the recursive and iterative approach is O(N) where N is the number of nodes we have in the binary tree.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Amazon Coding Interview Question - Sum of Left Leaves (LeetCode)», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.