Design Browser History - Leetcode 1472 - Python

preview_player
Показать описание


0:00 - Read the problem
0:35 - Drawing Explanation
4:45 - Coding Explanation

leetcode 1472

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

For this one I was able to easily come up with a doubly linked list solution but time complexity wasn't great. The array solution eluded me so it was nice to see it here.

Disusede
Автор

I wanna get a song “Hey everyone welcome back and let’s write some more needcode today”. That became an everyday motto. Thank you man for all work you are doing.

maxlievikoff
Автор

In a real world app I don’t think you’d ever want to use an array, as this would cause memory use to increase in an unbounded fashion over time. Whereas with a stack-based solution, every time you pop the memory can be freed/garbage collected. And in practice, O(n) traversal is perfectly fine since n would never be above a few hundred for a human user. You really don’t want a memory leak in your web browser. I know in a DSA interview the focus is usually on time complexity, but this tradeoff might be something good to discuss with an interviewer.

BenjaminCBaritone
Автор

lol I got this on an amazon phone screen a few months ago. totally bombed it

Simon-lkky
Автор

The array solution is quite clever! I just want to point out that in JavaScript you don't need the if/else statement in the visit method, since in JS there's no issue with setting the value of an out of bounds index. I coded it up with just `this.history[this.i + 1] = url;` and it works fine.

stylisgames
Автор

Hey Neetcode, just want to let you know that you're GOATED fr!
Best in quality explanation and code implementation 👏👏👏

tomiwaadedokun
Автор

I was waiting you to make the challenge of the day. But mine was different from you: "1519. Number of Nodes in the Sub-Tree With the Same Label" But thank you for this video and for the great explanation

basma-ba
Автор

for the browser history question, when you are using arrays, there doesn't seem to be the code that helps with truncating the browser history from the array, after you've visiting a new website. Shouldn't we ensure that all URLS beyond the current page are removed after visiting a new website? This is asked in the question "Visits url from the current page. It clears up all the forward history."

andytai
Автор

Bro, did you get a different daily question than others?

blutoo