Notes/Codes/Problem links under step 10 of A2Z DSA Course: takeuforward.org/strivers-a2z... Entire playlist: • Two Pointer and Slidin... Follow us on our other social media handles: linktr.ee/takeuforward
There was a slight mistake in the video. 1]. l++ in the while(cnt==m). 2]. It should be mp[s[l]]++; instead of mp[s[l]]--; in while(cnt==m) loop. string minWindow(string s, string t) { int l = 0, r=0; int n = s.size(), m = t.size(); int cnt = 0, minLen = 1e7; int startInd = -1; mapmp; for(int i=0;i
I think there are two points of Correction, that must have been missed : 1. hash[s[l]]++ as we are removing it while shrinking the string len. 2. we need to increment the l pointer at the end of the while loop where while(count == m). Striver did a great job! Thanks
@@tharungr7701 here you go string minWindow(string s, string t) { int n=s.size(),m=t.size(); map mp; int l{},r{},cnt{}; int len{1000000009},idx=-1; for(int i=0;i0) cnt--; if(r-l+1
@@tharungr7701 class Solution { public: string minWindow(string s, string t) { int n = s.length(); int m = t.length(); if (m > n) { return ""; } int minLength = INT_MAX; int sIndex = -1; map mp; for (int i = 0; i < m; i++) { mp[t[i]]++; } int l = 0, r = 0; int cnt = 0; while (r < n) { if (mp[s[r]] > 0) { cnt++; } mp[s[r]]--; while (cnt == m) { if (r - l + 1 < minLength) { minLength = r - l + 1; sIndex = l; } mp[s[l]]++; if (mp[s[l]] > 0) { cnt--; } l++; } r++; } return sIndex == -1 ? "" : s.substr(sIndex, minLength); } };
Thank you striver for the awesome playlist🎉🎉🎉🎉 In the optimal approach there was a slight mistake, inside the nested loop it should be hash[s[l]]++ instead of hash[s[l]]-- and after the check for if(hash[s[l]]>0)cnt--; , a line needs to be added for l++; to shrink the window c++ updated code - class Solution { public: string minWindow(string s, string t) { if (s.empty() || t.empty()) { return ""; } vectorhash(256,0); int l=0,r=0,minlen=INT_MAX,sind=-1,cnt=0; int n=s.size(),m=t.size(); for(int i=0;i
Hey can anyone tell me where is the mistake in my code its not passing all test cases. class Solution { public String minWindow(String s, String t) { char[] hash = new char[256]; for (int i = 0; i < t.length(); i++) hash[t.charAt(i)] += 1; int l = 0, r = 0, sIndex = -1, minlen = Integer.MAX_VALUE, count = 0; while (r < s.length()) { if (hash[s.charAt(r)] > 0) count++; hash[s.charAt(r)] -= 1; while (count == t.length()) { if (r - l + 1 < minlen) { minlen = r - l + 1; sIndex = l; } hash[s.charAt(l)] += 1; if (hash[s.charAt(l)] > 0) count--; l++; } r++; } if (sIndex != -1) return s.substring(sIndex, sIndex + minlen); return ""; } }
@@MayankPareek While initializing the hash you should use : int[] hash = new int[256]; Was there any reason why you chose to do a: char[] hash = new char[256];
@@ansulluharuka9243 yes! but i think there still some work is being done, so that may have caused u some problem in login, BUT let me tell you it's wind in there.
Completed the playlist within a day. Sliding window is usually an easier topic as it is totally intuition based, but to identify the patterns and making a structure for all the solutions, you made it look like piece of a cake. Thanks Striver
@@captain-ne8qy in the question we have to return our resultant substring right? So here we are iterating and all. Everything is fine but to return the substring, what do we want .....the first index of the substring, that is from where the substring is starting and the size so that we can calculate at what index the substring is ending, that's why we are storing both the starting index and size of the substring
Amazing work, Striver! You guys are really doing a great job for us by providing such a brilliant DSA course for free. It's genuinely useful for me. Please upload videos on strings in Striver's A2Z DSA Course/Sheet.......😇
Hey Striver, I watch all of your videos and love the way you explain things. I am stuck on a problem called Josephus Problem from a quite long time. Please make a video on it.
Completed this whole playlist in a single day. Thanks Striver for this. The way you teach makes me sit for long, think and implement and gradually the concepts start getting crystal clear.
MUCH MUCH MUCH love for your efforts @Striver, the new Website UI Rocks!! Also, can you please tell the ETA for string playlist? I'm really holding on from watching others' videos just so that I can follow yours ;)
recursion ki new playlist bhi le aao ( JAVA ) :---- class Solution { public String minWindow(String s, String t) { int l=0; int r=0; HashMap mpp=new HashMap(); int cnt=0; int sindex=-1; int minlen=Integer.MAX_VALUE; String st=""; for(int i=0;i
Thankyou so much Striver for all you efforts throughout in delivering us so much valuable content. Any student / working professional can now be able to transition their career without paying money for courses. Would also like your insights on the point : While preparing for interviews most of the aspirants are going through the videos solely and solving the question after completely watching the video. And also are feeling lazy trying to solve the question on our own. What is the best way to complete any topic without being lazy and how should an aspirant approach any topic/playlist?
Make playlist on CP problems for each algorithms atleast 30 each topic from 1200 div to 1800div CP SHEET of yours has very less problems except for dp and math 😢
i lost all my progress with the new website update, when i logged in it again and marked my progress i lost it again and it says unautorized . The old website ui was much user friendly and better . The new update just made it more complex to navigate
Day 2 of asking Hey Striver, When can we expect solution videos for Strings, Stack and Queues, few Recursion videos as these are on top of queue, for A to Z sheet everyone needs them Love your content and teaching methods way from Brute to Optimum teaches us alot
I enjoy grasping from your videos StriverBhai !! I wanted to highlight one mistake in code that inside while(cnt==m) you did hash[s[l]]-- but it should be hash[s[l]]++ as the condition is if(hash[s[l]]>0) cnt--; and you forgot to write l++ as well.
Please make a playlist on Heaps and Priority Queue Sir. Since Placement session is going too start requesting you to please upload it soon. Please Sir.
Hello , striver , in your dsa a-z course , in step 17 and 18, tries and strings some videos are missing , will be soon said , would these videos come ?
Hey Striver, Its been 40 days. Please upload recursion patten wise video first . because recursion is required in advance topic like DP and graphs. So if we have recursion playlist complete we can go to DP and graph with confidence
Hey can anyone tell me where is the mistake in my code its not passing all test cases. class Solution { public String minWindow(String s, String t) { char[] hash = new char[256]; for (int i = 0; i < t.length(); i++) hash[t.charAt(i)] += 1; int l = 0, r = 0, sIndex = -1, minlen = Integer.MAX_VALUE, count = 0; while (r < s.length()) { if (hash[s.charAt(r)] > 0) count++; hash[s.charAt(r)] -= 1; while (count == t.length()) { if (r - l + 1 < minlen) { minlen = r - l + 1; sIndex = l; } hash[s.charAt(l)] += 1; if (hash[s.charAt(l)] > 0) count--; l++; } r++; } if (sIndex != -1) return s.substring(sIndex, sIndex + minlen); return ""; } }
Hello Striver, the menu bar does no longer contain a link to tree Series in sub Category "DSA playlist". i was actually near to completion with only four questions left when the website suddenly updated could you please add the category again . thank you followed your playlist to the end. "A problem in website in takeuforward."
hey Striver ,you forgot to increment the l pointer and also in hash[s.charAt(l)]--; it should decrese the number but the value is increasing (example for d -> -2 if we perform hash[s.charAt(l)]--; (-2-1 => -3) so it should be hash[s.charAt(l)]++; (-2+1 => -1) thanks for the amazing Playlist.
Hey Striver, I know you have very busy schedule but please drop playlist quicker. Because I started Binary tree as all other playlist before it was completed. But on the hard question it require proper knowledge of Queue and Stack , Priority Queue. Which is not completed in the playlist. So learning became difficult. Hope you understand.
Anyone else is having issues with the new website? I am seeing unauthorized. As soon as I sign it is all fine but when I go to A2Z sheet or any section of the website it says that Unauthorized. Why is it happening
I think there is slight correction in the pseudocode, I made these corrections while doing the problem I am posting it here ya'll can refer to it if you are facing problem, " map mp; for(int i=0;i
Bro i have a doubt if the hash[s[left]]-- then the character to be inserted to the hash right but hash[s[left]] to be incremented to reduce the value if it is positive then count should be decremented please resolve my doubt bro
thanks striver for this problem statement here is the optimal solution with comments that will help me and you when we do revision for this type of question class Solution { public: string minWindow(string s, string t) { // if(s == t) return s; // if the both strings are equal then we dont have to go down; int cnt = 0; int minLen = INT_MAX; int l= 0; int r =0; int n = s.size(); int index = 0; //creating the hash map to keep therecord of the value unordered_map mpp; for(int i =0 ; i< t.size(); i++){ mpp[t[i]]++; //making flags so that they will help us for the count; } while(r= 0){ cnt ++; } //making the condition for the count while(cnt == t.size()){ //setting the index according the min length if(r-l+1 < minLen){ index = l; //then you update the index; } //first we get the current length and compaire it with our minLen minLen = min( minLen, r-l+1); //now we try to shrink the substring therefore we move l++; mpp[s[l]]++; if(mpp[s[l]] == 1){ cnt = cnt-1; } l++; } //after shirinking we need to extend r++; } //if wwe want to send "" string as an output if(minLen == INT_MAX) return ""; //getting the stirng by the size minLen // index to minLen; wala part return s.substr(index, minLen); } }; keep liking this comment so youtube will notify me about this imp question :) :)
when we click on open in new tab (video)both videos started and sounds mixed together .....so may be we can inhace this loop hole of new website master
bhaiya website update hone ke baad jab koi bhi topic ke article kholte hai to undefined tutorial likha ata hai....The articles are not opening.If possible please resolve this issue as soon as possible.It will be a great help.Thank you.....
Bhaiya are u Odia ?? I actually saw you house vlog ang got to know it. Actually I am native from Cuttack, but studing in kiit in 2nd sem. Can you plss. provide me some tips for my carrer. My branch is CSCE
what u did to TFU website man , crashing a lot .. some login issue and token refresh not happening properly looks like But good UI , just fix login issues ...
CODE IN C++ class Solution { public: string minWindow(string s, string t) { unordered_map mpp; int l=0,r=0,c=0,m=t.size(),index,minlen=INT_MAX; for(int i=0;i
In the first approach, the nested for loop should be from j=i to n instead of j=0 to n, because we are checking for each substring DOES ANYBODY THINKS THE SAME ?