Repeated Substring Pattern - LeetCode #459 with Python, JavaScript and Java

preview_player
Показать описание
Let's solve LeetCode #459 Repeated Substring Pattern!
------------------------------------------------------------------------------------------------------
My channel has a lot of videos to prepare for technical interviews. I explain all details of the questions and write codes in the video. You can get the codes from Github for free. If you like my channel or videos, please subscribe it, hit a like button or leave your comment. Thank you for your support!

Please subscribe the channel from here.
------------------------------------------------------------------------------------------------------

■ Timeline
0:00 Read the question of Repeated Substring Pattern
1:39 Explain a basic idea to solve Repeated Substring Pattern with O(n^2)
4:34 Coding with O(n^2)
6:44 Time Complexity & Space Complexity
8:11 Explain a basic idea to solve Repeated Substring Pattern with O(n)
9:58 Coding with O(n)
10:22 Time Complexity & Space Complexity

■ Problem Link

■ Codes in the video
- Python with O(n^2)

- Python with O(n)

- JavaScript with O(n^2)

- JavaScript with O(n)

- Java with O(n^2)

- Java with O(n)

■ Playlists

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

Hey, thanks for sharing the video. I must say, your response really impressed me – very elegant.

While grappling with this particular problem, I invested an extended period of time in arriving at a resolution. Ultimately, I employed a z-function to identify recurring patterns within the string, achieving a time complexity of O(n).


Funny thing happened when I translated your solution to Rust. It actually clocked in 2% faster than my z-function gambit. Kudos to your approach!

I'm curious, though. What was the "a-ha" moment that led you down this clever path? What intuition did you use so think of this answer? Was it just experience of having worked with a similar problem before? Or do you have a particular set of heuristics to employ when trying to solve this specific category of problem.

aleksandermirowsky
Автор

I explain how to solve this question when i = 2. There is a difference between what I say and what you see. Sorry for confusion.

And the first approach has better time complexity than what I say. See a comment in the article.

CodingNinjaExAmazon
join shbcf.ru