Word Break | Dynamic Programming | Leetcode | 60 Interview problems

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

Here is the solution to a nice coding interview problem on leetcode.
And here is a super useful blog that enlists 60 important coding problems.

Hope that you will find this useful!
Do like share and subscribe if you enjoy the videos posted by me :)
Super useful books for algo ds and programming fundamentals!

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

Nice explanation sir....thanks for the video.

paragroy
Автор

I actually first opened your video as i couldn't find on my own. But at that time just before it struck to my mind--front partition.

Here is my code:
bool check(int i, int j, string &s, unordered_set<string>&st){
string k="";
for(int r=i;r<=j;++r){
k.push_back(s[r]);
}
return st.count(k);
}
bool func(int i, string &s, unordered_set<string>&st, vector<int>&dp){
int n=s.size();
if(i>=n){
return 1;
}
if(dp[i]!=-1){
return dp[i];
}
bool ch=0;
for(int j=i;j<n;++j){
if(check(i, j, s, st)){
bool ans=func(j+1, s, st, dp);
if(ans){
return dp[i]= 1;
}
}
}
return dp[i]=0;
}
bool wordBreak(string s, vector<string>& arr) {
unordered_set<string>st;
for(int i=0;i<arr.size();++i){
st.insert(arr[i]);
}
vector<int>dp(s.size()+1, -1);
return func(0, s, st, dp);
}

Rahul-lsju
Автор

Please try to explain roughly in another platform how you going to solve problems..what would be is your first step and last step. I didn't understand properly.

AvinashKumar-pstw
Автор

Pls make some drawing for the approach as well, it will really help.

ChandraShekhar-bycd
Автор

Rather than using a set you can directly use find() for vector.

naivedhshah
Автор

Hey guys!
Some people wanted me to explain the solution in more detail and I take the feedback very seriously.
So in response to that I have uploaded another video which goes over the entire thought process to solve the problem.

AlgosWithKartik
Автор

This list is my target 22/60 solved and learning is important

midhileshmomidi
Автор

Please make a video on how to get resume shortlisted in top companies without referral.

tecHSonic
Автор

i think this is not the most optimised one as it is showing tle on interviewbit. Can you please explain the solution which doesnt use hashset.

jatinbhatoya
Автор

Bhai coding problems discuss karte rehna
It helps a lot

kartikbhardwaj
Автор

It will be great if you could make videos on problems which are not there on judge but are asked in various interviews may be you can take google coding problems from leetcode discuss

code
Автор

Thank u so much bhaiya, DP has started, thanx :)

LeoLeo-nxgi
Автор

Bro can you explain codechef long challenge questions ? (especially the hard ones)

NotFound-hyqb
Автор

Very helpful video. Thanks a lot. Pls upload more video on leetcode medium problems. Thanks for your effort

ChandraShekhar-bycd
welcome to shbcf.ru