Extra Characters in a String - Leetcode 2707 - Python

  Рет қаралды 18,633

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 26
@rohitkumaram
@rohitkumaram 2 ай бұрын
I think, I need to complete the eligibility to understand, these solutions, 1st DP always pain for me , then Trie. Have marked will try again after few , hopefully that time I could understand this solution.
@UmarKhan-rb3ts
@UmarKhan-rb3ts Жыл бұрын
The way I went about doing it is the same dp memoisation approach but instead of creating all possible substrings of the string starting the ith index, I iterated over the dictionary words and took the subtring of the given string starting ith index exactly the same length as each dictionary word. However,I don't think there is a great difference in time complexity.
@kusumjoshi4613
@kusumjoshi4613 2 ай бұрын
Can you please share that code
@poojababa67
@poojababa67 Жыл бұрын
The explanation is as neet(neat) as it could get!
@MP-ny3ep
@MP-ny3ep Жыл бұрын
Great Explanation !
@rajrajesh1669
@rajrajesh1669 Жыл бұрын
Nice explanation
@chien-yucode992
@chien-yucode992 Жыл бұрын
YOU ARE AWESOME
@MartinDeveloper-j9r
@MartinDeveloper-j9r 2 ай бұрын
Hi, thanks for posting this video, this is very helpful. Quick question, why do you set dfs(j + 1) in line 33, `res = min(res, dfs(j+1)`. It seems that position, j + 1, is already calculated, so can we call the dp, `dp[j+1]` instead of doing a dfs(j + 1)? Though the if statement will catch it and call the dp. Just curious if there is reason why. Thanks :)
@pixelbyteee
@pixelbyteee 2 ай бұрын
Dp[j+1] might not be calculated yet, so we cannot guarantee a solution there... But calling recursively solves that issue
@ShivangiSingh-wc3gk
@ShivangiSingh-wc3gk 2 ай бұрын
Please can someone correct my understanding Runtime with just recursive 2 ^(n^2) With memoization o n^2 ?
@rocmewtwo
@rocmewtwo 2 ай бұрын
slicing substring s[i:j+] also takes O(n), so with memorization is O(n^3). dfs -> n, j inner loop -> n, slicing -> n if using trie, we can reduce the time slice and compare prefixes.
@soumyajitchatterjee5822
@soumyajitchatterjee5822 Жыл бұрын
Damn. This was a really great solution.
@light_70
@light_70 Жыл бұрын
Thanks :)
@abdulrhmankhattab9041
@abdulrhmankhattab9041 Жыл бұрын
ty
@berserk.4121
@berserk.4121 Жыл бұрын
What kind of app(board) he uses to draw
@ZiruiLiu
@ZiruiLiu Жыл бұрын
I really doubt if these companies will continue to select candidates based on their leetcode coding performance in the future.
@adamsmith9590
@adamsmith9590 11 ай бұрын
Why
@thepriestofvaranasi
@thepriestofvaranasi 2 ай бұрын
Why
@Rancha51
@Rancha51 Жыл бұрын
Can you please do Odd Even Jump ? been waiting for that a long time now
@Nisha.......
@Nisha....... Жыл бұрын
problem number?
@Rancha51
@Rancha51 Жыл бұрын
@@Nisha....... Leetcode 975
@Nisha.......
@Nisha....... Жыл бұрын
@@Rancha51 Just tried it using DP, here's the solution: class Solution: def oddEvenJumps(self, arr: List[int]) -> int: n=len(arr) x=[[False,False] for i in range(n)] # odd, even # set both even jump and odd jump of last element to true x[-1][0]=True x[-1][1]=True for i in range(n-2,-1,-1): cur1=[inf,inf] cur2=[-inf,inf] for j in range(i+1,n): if arr[j]>=arr[i] and arr[j]
@Rancha51
@Rancha51 Жыл бұрын
@@Nisha....... Thanks for the effort, appreciate it. But I am looking for explanation not the code.
@swastikgorai2332
@swastikgorai2332 Жыл бұрын
can we do it like word break??
@ahmedashraf3199
@ahmedashraf3199 Жыл бұрын
could u consider a c++ solution next time ? ty alot.
@高进-k1h
@高进-k1h Ай бұрын
what is definition of your dp,or what is subproblem definition?
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 150 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 695 М.
Do you love Blackpink?🖤🩷
00:23
Karina
Рет қаралды 21 МЛН
K-th Symbol in Grammar - Leetcode 779 - Python
10:19
NeetCodeIO
Рет қаралды 14 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 253 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 330 М.
Champagne Tower - Leetcode 799 - Python
13:48
NeetCodeIO
Рет қаралды 12 М.
My Brain after 569 Leetcode Problems
7:50
NeetCode
Рет қаралды 2,7 МЛН
COMPUTER SCIENCE explained in 17 Minutes
16:49
Wacky Science
Рет қаралды 1,5 МЛН
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 586 М.
Longest String Chain - Leetcode 1048 - Python
15:34
NeetCodeIO
Рет қаралды 10 М.
Errichto Stream, POI 22/1
3:55:08
Errichto Algorithms
Рет қаралды 171 М.
Decode String - Leetcode 394 - Python
16:26
NeetCode
Рет қаралды 93 М.
Do you love Blackpink?🖤🩷
00:23
Karina
Рет қаралды 21 МЛН