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.
@@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]
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.
The explanation is as neet(neat) as it could get!
Nice explanation
Great Explanation !
YOU ARE AWESOME
Damn. This was a really great solution.
I really doubt if these companies will continue to select candidates based on their leetcode coding performance in the future.
Why
Thanks :)
What kind of app(board) he uses to draw
ty
can we do it like word break??
Can you please do Odd Even Jump ? been waiting for that a long time now
problem number?
@@Nisha....... Leetcode 975
@@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]
@@Nisha....... Thanks for the effort, appreciate it. But I am looking for explanation not the code.
could u consider a c++ solution next time ? ty alot.