Why is like after watching your explanations, every problem looks easy!
@josecabrera79472 жыл бұрын
Dude mark my words if I get this internship with google or amazon in Seattle for summer 2023 I will personally take you to dinner !!!!
@servantofthelord81473 ай бұрын
were you able to get it?
@illu1na11 ай бұрын
Can you also cover the follow up question for this problem please?
@a4rdev2 жыл бұрын
Was struggling to understand two pointers. This is a great place to start. Thanks
@navaneethmkrishnan63742 жыл бұрын
A lot of people ask why the question is given under the DP tag. This is because to find the length of the longest common subsequence, we need DP.
@nanoname52263 жыл бұрын
Could you also address the follow up element of this problem? The one that talks about a stream of query strings "s" coming in.
@vasujhawar.698711 ай бұрын
thats why I came here
@jayjw18 ай бұрын
I'm not sure if there's more to it, but wouldn't you just check if s > t: return False automatically because s can't be a subsequence if it's larger than the entirety of t?
@gamba36854 күн бұрын
@@jayjw1 No, the follow-up element isnt talking about any specific s, it's talking about how to be more efficient if there are multiple s being sent to our function, how can we evaluate each s in an efficient way?
@farrukhniaz3218 Жыл бұрын
instead of if else in return statement, write return i == len(s)
@buzunoorrishika8690 Жыл бұрын
Thank you so much I was able to write my own Java code by using your logic
@achraftasfaout29602 жыл бұрын
Pretty neet answer, thanks. The return statement could've been: return i == len(s)
@fanyang97773 жыл бұрын
awesome lesson as always!
@jaideepsingh79552 жыл бұрын
How is this a DP problem ? Can u plz elaborate how this is breaking up into overlapping subproblems and optimal substructure ?
@navaneethmkrishnan63742 жыл бұрын
To find the length of the LCS, we need DP. This one is a simple two-pointer solution.
@anutoshghosh78936 ай бұрын
In the two pointer approach, I did not understand one thing the ordering also has to be checked in a subsequence which is missing for the problem in the testcases, for instance here s = "acg" and t = "ahbgdc", they are considering s as a subsequence of t which should not be so, as the ordering is not maintained, although all elements are present from s in t.
@ryanbaker7419Ай бұрын
did u ever figure it out? im wondering the same
@danielsun716 Жыл бұрын
DP solution: It is easy to think of this if you finished 10. regular expression matching. def isSubsequence(self, s: str, t: str) -> bool: if len(s) > len(t): return False dp = [[False] * (len(t) + 1) for _ in range(len(s) + 1)] for j in range(len(t) + 1): dp[len(s)][j] = True for i in range(len(s) - 1, -1, -1): for j in range(len(t) - 1, -1, -1): match = s[i] == t[j] if match: dp[i][j] = dp[i + 1][j + 1] else: dp[i][j] = dp[i][j + 1] return dp[0][0]
@iosifpuha6114 Жыл бұрын
this man is a hero
@cryptohamsterx5 ай бұрын
bro are you genius!!
@flatmapper Жыл бұрын
Thank you NeetCode. One can just return `i == len(s)`
@arunimachakraborty117510 ай бұрын
Thank you so much. You saved my day
@akshatverma8385 ай бұрын
you earned a subscriber today 👍👍.
@sa250782 жыл бұрын
Thanks a lot .This video helped me a lot !!
@krateskim416911 ай бұрын
Awesome explanation
@bilalmohammad4242 Жыл бұрын
Thank you very much!
@lamatenzin8756 Жыл бұрын
but wouldn't the while loop keeping looping endlessly if i is never incremented? because your'e only incrementing i if s[i] = s[j]. what if it never equals ?
@srx210610 ай бұрын
then j will keep incrementing and eventually stop the loop
@love2code_official3 жыл бұрын
Thank you bro.A love from tamil nadu
@RocketPropelledWombat Жыл бұрын
This one killed me for some stupid reason -.-
@elias0430113 ай бұрын
return i == len(s) concise
@yashsolanki0698 ай бұрын
I'm still Scratching my head, what if it's not in the sequence?
@sanjeevacham24002 жыл бұрын
Excellent
@sriramprasanth33903 жыл бұрын
Bro what if it is wrong order acb,abcdef
@Track-Tor3 жыл бұрын
he explains it at 1:32
@DanhWasHere3 жыл бұрын
Then it won't be a subsequence, as he explained
@kanikasaxena8603 Жыл бұрын
It is handled through increment of j
@praneeth83802 ай бұрын
def isSubsequence(s, t): if all(j in t for j in s): return True else: return False