Implement Stack Using Queues | LeetCode 225 (One Queue) | Coding Interview Tutorial

preview_player
Показать описание
Implement Stack Using Queues solution: LeetCode 225

AFFILIATE LINKS
If you're interested in learning algorithms, these are great resources.

💲 All coupons and discounts 💲

Implement Stack Using Queues | LeetCode 225 (One Queue) | Coding Interview
#implementstackusingqueues #leetcode #algorithms #terriblewhiteboard #codinginterview

Click the time stamp to jump to different parts of the video.
00:00 Title
00:06 Whiteboard solution
03:52 Coding solution
08:14 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!

TerribleWhiteboard
Автор

Day 2/40: Took me a while to wrap my head around the .push() implementation. I had something that was using unnecessarily rotating the .push() .pop() and .top() methods, but eventually I came to terms with your more simple approach. By the way, we can also use a for loop for the rotations cycle in the .push() method. Runtime was 50 ms (faster than 99.10%)!

MyStack.prototype.push = function (x) {
const rotations = this.primaryQueue.size();

this.primaryQueue.enqueue(x);

for (let i = 0; i < rotations; i++) {

}
};

IRLVaporwave
Автор

Thanks. I saw this algo and coded in python. It worked perfectly fine

kumarpriyansh
Автор

thanks. is it a must to use prototype here?

alenamitnovizki
Автор

If i am interested in front end engineering, should i focus on using JS for these problems, or could I use any for these and an interview?

tannerbarcelos