Google Coding Interview Question - Validate Stack Sequences (LeetCode)

preview_player
Показать описание
Here is a step by step explanation of a popular Google question involving the use of a stack called "Validate Stack Sequences" on LeetCode. This problem is of medium difficulty and the goal of the problem is to see if after taking in two separate arrays "pushed" and "popped" determining if we can perform the push and pop operations in a particular order. By the end of performing both of the push and pop operations on all of the elements in our arrays, we return true from our function if our stack is empty.

The time and space complexity of this optimized solution is linear, where N is the size of either our "pushed" or "popped" array. Our arrays will always be the same length, so O(N) is the final runtime and space time.

Check out my interview prep platform for learning the patterns!

Рекомендации по теме
Комментарии
Автор

Love your patience of going through the example step by step! Thank you for the video.

jyl
Автор

I get so happy when I youtube search a question and see you have a video on it 👏🏿👏🏿👏🏿 I like the video before watching!

MayaBello
Автор

such a great visual with decent visualization. Thank you. Pls keep it up!

traton
Автор

thanks, i did not understand the solution on leetcode at all, this video helped a lot!

juanthepaab
Автор

Great Explanation Bro...
Loved the way you taught!!

mriduljain
Автор

Will it work if our push and pop array contains repeated elements?

AmruthaMU
Автор

can we also use the stack an indication of possible push pop operation? Meaning if the stack is empty can we use that to return the answer. If there are still elements on the stack we return false. if not stack => True

ousmandiallox
Автор

Add more tricky and nice interview problems

code
Автор

Is there a proof that this solution would work for this question for all cases?

hemangakrishnaborah
visit shbcf.ru