Concise code for the problem: string minWindow(string s, string t) { unordered_map mp; int minlen=INT_MAX, start=0; for(auto ch:t){ mp[ch]++; } int i=0,j=0,count=mp.size(); while(j
@sarveshmaurya21682 жыл бұрын
commenting for better reach ( according to the explanation) great
@MaheshKumar-ur8hq Жыл бұрын
CFBR
@littleworld302110 ай бұрын
CFBR
@DarthVader6789 ай бұрын
Please note that instead if(mp[s[i]]==1) it will be if(mp[s[i]] > 0)
@KaranSaini-uw7yi9 ай бұрын
good
@TheAdityaVerma3 жыл бұрын
I haven't included the code of this problem in this video and not uploading it right now (although I have it ready): for two reason: 1) Video was getting too long. 2) I want you guys to do it by yourself, since this will be last video in this series and this is the "BAAP" problem of sliding window, if you can do it, I can assure you will be able to do almost any sliding window problem. Try it by yourself, I will upload soon :)
@nishthagoel75423 жыл бұрын
Thank you so much, Aditya. Pleaseee upload BFS & DFS (i am having trouble with imp questions like number of islands etc) your videos have been very helpful :)
@akhilmehta82483 жыл бұрын
Hello, I tried to write its code, but getting few errors. Can you please upload the code on github or in another video?
@devilronak72623 жыл бұрын
Bhai you are great your videos are very helpful, plz make videos on backtracking plz🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
@rv0_03 жыл бұрын
upload nhi kiye
@rubinip19563 жыл бұрын
Kindly add subtitles..so it Will be useful for everyone
@mayank60233 жыл бұрын
Vote for backtracking series.
@Jadon093 жыл бұрын
@Aditya verma what does it mean?
@achintyaveersingh46513 жыл бұрын
@@Jadon09 It's a traveling fake salesman problem
@SoftwareDeveloper863 жыл бұрын
definetly intrested,
@dhirendrasingh6071 Жыл бұрын
This is his last uploaded video
@Mohit-gb9dv Жыл бұрын
@rithikraj18133 жыл бұрын
I tried to find your social media link but couldn't find it, because of you only got placed in VMware Interview mei pucha mrese ki node to node max sum path ka value nikalna h aur hm yeh thumb nail mei dekhe the yaad tha qstn but soln nii aata tha ab hmko smjh nii aara tree mei dp kaise lgega kahe ki yeh dp playlist mei h aur interviewer smjh gya ki hmko yeh qstn aata nii h kahe ki hm bhot cross qstn krre end mei solve huaa aur vo next Interviewer ko itna aacha review diye ki baapre kisi ne reject nii krra aur mreko hr mei bola gya face mei ki I got selected for intern + fte Bhai sir literally bow to your expertise ❤️❤️ aur stack ko sort krne v bola recursively vo v bna diye hm uska v video h apka playlist mei bhai bnate rhiye aisa video bhot help hota h ❤️❤️
@haritmohan13263 жыл бұрын
Hello Sir, I never thought coding could be this enjoyable before watching ur videos, eagerly waiting for your series of GRAPHS and TREES.☺️
@Ash-fo4qs2 жыл бұрын
yes graph and all the other remaining topics🙈.
@akankshasinha33522 жыл бұрын
Hi … please tell , how to build concept for rest of the linkedlist and trees kind of problem? Cz everything is not covered on this channel ! 🥺😔 gimme some ideas
@ytg66632 жыл бұрын
Keep waiting 😂😂😂
@ytg66632 жыл бұрын
@@akankshasinha3352 u may refer to other channel take u forward / striver / techdose
@VinayKumar-ze2ww2 жыл бұрын
@iblis take u forward
@Omchaudhary0716 күн бұрын
Generally, I don’t comment on any video, but this is genuinely the best video because it teaches how we should approach a problem. I've seen many tutors, but they mainly focus on solving a problem, whereas he is the only one who explains how we should approach it
@mrugeshsabalpara67553 жыл бұрын
Idea behind iterating Given String length can thought as : 1) Iterate thru string S till the count [map size from String T characters] variable reaches to 0. 2) Once counter is 0, try to move the start pointer towards end pointer to minimize the length of the found substring. If character at start pointer matches with string T increment the count variable. Loop thru till count variable is 0. // String s = "timetopractice"; String t = "toct"; int sLen = s.length(); int tLen = t.length(); if(tLen > sLen) System.out.println("Invalid Input"); HashMap countMap = new HashMap(); for (char c: t.toCharArray() ) { countMap.put(c,countMap.getOrDefault(c,0) + 1); } int start = 0; int end = 0; int maxLen = Integer.MAX_VALUE; int maxStart = 0; // to track Start index of substring int maxEnd = 0; // to track End index of substring int count = countMap.size(); while (end < sLen){ char tempCharEnd = s.charAt(end); if(countMap.containsKey(tempCharEnd)){ countMap.put(tempCharEnd,countMap.get(tempCharEnd) - 1); if(countMap.get(tempCharEnd) == 0){ count--; } } while (count == 0) { if(maxLen > end - start + 1) { maxLen = end - start + 1; maxStart = start; maxEnd = end + 1; } char tempCharStart = s.charAt(start); if (countMap.containsKey(tempCharStart)) { countMap.put(tempCharStart, countMap.get(tempCharStart) + 1); if (countMap.get(tempCharStart) > 0) { count++; } } start++; } end++; } System.out.println(maxLen); System.out.println("Start Index : " + maxStart +" End Index :" + maxEnd + ": "+ s.substring(maxStart,maxEnd));
@adityajain51012 жыл бұрын
string result=""; unordered_map mp; for(int m=0;m
@akankshasinha33522 жыл бұрын
Hi … please tell , how to build concept for rest of the linkedlist and trees kind of problem? Cz everything is not covered on this channel ! 🥺😔 gimme some ideas
@arpankesh8722 жыл бұрын
@@adityajain5101 Try this one, it passes all the test cases. In your code it should be if(mp[s[i]] > 0) count++; My code :- string result=""; unordered_map mp; for(int m=0;m
@kunaldas92842 жыл бұрын
you don't need maxEnd if you've already found the min lngth i.e. s.substring(maxStart, maxStart + maxLen+1)
@debangshubanerjee13112 жыл бұрын
The condition - if (countMap.get(tempCharStart) > 0) { count++; } is wrong coz here count represents the count of distinct characters, not the count of all characters. It should be -: if (countMap.get(tempCharStart) =1) { count++; }
@JangBahadur30283 жыл бұрын
Aditya bhaai, please upload your videos more frequent like before... I'm preparing for interviews and need your styled videos on backtracking and greedy algorithms. You are my favourite teacher.
@Abc-lr4bf Жыл бұрын
WOW aditya bhayia, kitna badia samjhaya hai aapne , khud se code pass karvane ki jo khushi hoti hai na kya hi batau , thanks a lot
@krishgarg56652 жыл бұрын
I am in 4th year and I feared coding from 1st year but YOU HAVE REMOVED MY FEAR!! God bless you, love you bhai...please cover all the topics like graphs and trees as well
@vivekswami2182 Жыл бұрын
already covered by striver
@NewBIE-xz5jm9 ай бұрын
Then why are you here! lol @@vivekswami2182
@rupalitiwari50122 жыл бұрын
Thanks Aditya. Below is the java solution based on this explaination. Java Solution : class Solution { public String minWindow(String s, String t) { String ans=""; int i=0,j=0; int min=Integer.MAX_VALUE; HashMap map=new HashMap(); for(int k=0;k0) count++; i++; } if(count==0) { if(min>j-i+1) { ans=s.substring(i,j+1); min=j-i+1; } } } } j++; } return ans; } }
@mysterious57297 ай бұрын
Here is bit improved code class Solution { public String minWindow(String s, String t) { String ans=""; int i=0,j=0; int min=Integer.MAX_VALUE; HashMap map=new HashMap(); for(int k=0;k0) count++; } i++; } } } return ans; } }
@itsrahimuddinkhan3 жыл бұрын
Please start a series on trees and graphs.
@shashwatrai19893 жыл бұрын
Bhaiyya we really need more content! You have spoiled us so much that we cannot settle for anyone else! Please consider doing a series on graphs and/or backtracking.
@sriramkrishnamurthy44733 жыл бұрын
Bruh
@sohamnandi47083 жыл бұрын
Please make a Series on Backtracking, Graph, Tree, Hashing & Number System
@ritikshandilya70757 ай бұрын
Aditya bhai , sari playlist ka security tight krva lo . Its PURE GOLD 🔥. Thanks for great approach
@divyranjan2543 жыл бұрын
I solved almost all of the string based sliding window questions using count of distinct numbers technique in one way or another... It's such an OP trick
@akankshasinha33522 жыл бұрын
Hi … please tell , how to build concept for rest of the linkedlist and trees kind of problem? Cz everything is not covered on this channel ! 🥺😔 gimme some ideas
@vishalgupta9572 жыл бұрын
@@akankshasinha3352 search tuf , striver has covered variety of problems on trees, first get a basic idea of how recursion works, then trees will be a cakewalk for you. Linkedlist are easy dude. it will come along with some practice.
@akankshasinha33522 жыл бұрын
@@vishalgupta957 thankyouuuuu 😋😋 i
@uavishal7772 жыл бұрын
I don't know why subscriber are less at this Channel...No one can Compare to Aditya Bhaiya...He is amazing to make people understood what he teach... Lots of love to your effort and your way of teaching.
@anamaysrivastava12193 жыл бұрын
Sir, please bring in new lectures on remaining topics . Your observations has really been a boon to all of us .
@anshulkumar78713 жыл бұрын
Start uploading again, please. We need you. Jaldi aao.
@prakhanshubharadwaj15453 жыл бұрын
Please make a series on tree and graphs ... Please!
@swarbhatia3 ай бұрын
This one was a bit trickier than the rest but managed to code it after a few attempts. Amazing playlist, I have personally seen a lot of question based on the limited patterns covered in this playlist! Very helpful!
@varshalisingh58353 жыл бұрын
Why have you stopped making videos?...Your content is just awesome.
@nagpuri4390 Жыл бұрын
Bro can u pls help in the leetcode 1838 frequency of most frequent element question??? Using Aditya Sir approach
@raghavagrawal62632 жыл бұрын
Tried implementing in Python.. def minimumSubstringWindow(strng, t): count_map = dict() n = len(strng) for ch in t: if ch in count_map: count_map[ch] += 1 else: count_map[ch] = 1 start = 0 end = 0 map_size = len(count_map) min_window_len = 1000000007 maxStart = 0 maxend = 0 while end < n: if strng[end] in count_map: count_map[strng[end]] -= 1 if count_map[strng[end]] == 0: map_size -= 1 while map_size == 0: min_window_len = min(min_window_len, (end - start + 1)) maxStart = start #substring start index maxend = end+1 #substring end index ch_start = strng[start] if ch_start in count_map: count_map[ch_start] += 1 if count_map[ch_start] > 0: map_size += 1 start += 1 end += 1 print("substring start index {} and end index {}".format(maxStart, maxend)) return min_window_len
@SUMITKUMAR-rt5bs3 жыл бұрын
working code in C++ According to Aditya Bhai's Explanation Hope this help!!!! #include using namespace std; int main() { string s="totmtaptat"; string s1="tta"; // Making the Map unordered_map mp; for(int i=0 ; i
@malkeetsapien48522 жыл бұрын
Thanks Man !
@Amansingh-gi3gx Жыл бұрын
,🔥🔥❤️
@satyajeetrajupali31476 ай бұрын
int minWindowSubstring(string s, string t) { int i = 0; int j = 0; int ans = INT_MAX; int n = s.length(); unordered_map mp; int count = 0; for (char c : t) { if (mp.find(c) == mp.end()) mp[c] = 0; mp[c]++; } count = mp.size(); while (j < n) { if (mp.find(s[j]) != mp.end()) { mp[s[j]]--; if (!mp[s[j]]) count--; } if (count > 0) j++; else if (count == 0) { while (count == 0) { ans = min(ans, j - i + 1); if(mp.find(s[i]) != mp.end()){ mp[s[i]]++; if(mp[s[i]] == 1) count++; } i++; } j++; } } return ans; }
@willturner34403 жыл бұрын
I was stucked in this problem for last 3 hrs but after watching your video I was able to code in single run 😃
@udityakumar9875 Жыл бұрын
Thanks a lot for this awesome playlist . just completed and pretty much confident to solve most of the sliding window problems now
@nagpuri4390 Жыл бұрын
Bro can u pls help in the leetcode 1838 frequency of most frequent element question??? Using Aditya Sir approach
@sarthaksoni78643 жыл бұрын
Subscribed. Hands down best content on youtube. I recently stumbled upon a problem I couldn't solve. Take a look into this mate might even be an addition to the playlist. the question - Given a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is greater than or equal to k. Input: s = "aaabb", k = 3 Output: 3 Explanation: The longest substring is "aaa", as 'a' is repeated 3 times. Input: s = "ababbc", k = 2 Output: 5 Explanation: The longest substring is "ababb", as 'a' is repeated 2 times and 'b' is repeated 3 times.
@payaljain40153 жыл бұрын
string minWindow(string s, string t) { int size=t.length(); int size1=s.length(); if(size>size1) return ""; string ANS = ""; mapm; for(int i = 0; i < size; i++){ m[t[i]]++; } int i=0,j=0,ans=INT_MAX; int count=m.size(); while(j
Bhai tu best h Plss saare concepts pe video banado. I have enrolled in Coding blocks, Simplilearn and now HEYCOACH cohort fot DSA. Prr conecpts strong sirf teri videos se hote hai. Please saare concepts pe video banao bhai, IN THE SAME FORMAT PLease. Apna way of teaching and format constant rakhna bas. I always recomment you to everyone, who needs DSA!! U r best bro. Keep it up
@shashankkr10083 жыл бұрын
Sir, never stop doing this, gold content
@abdussamad03482 жыл бұрын
finally after so many tries of dry run. Here is the Js approach. function minimumWindowSubstring(s, k) { let [start, end, count, ans] = [0, 0, 0, Infinity]; let ansString = ""; const obj = {}; for (let i = 0; i < k.length; i++) { obj[k[i]] = (obj[k[i]] || 0) + 1; } count = Object.keys(obj).length; while (end < s.length) { if (count !== 0) { if (obj.hasOwnProperty(s[end])) { obj[s[end]]--; } if (obj[s[end]] === 0) { count--; } if (count !== 0) { end++; } } if (count === 0) { if (ans > Math.min(ans, end - start + 1)) { ans = Math.min(ans, end - start + 1); ansString = s.slice(start, end + 1); } if (obj.hasOwnProperty([s[start]])) { obj[s[start]]++; } if (obj[s[start]] == 1) { count++; end++; start++; continue; } start++; if (ans > Math.min(ans, end - start + 1)) { ans = Math.min(ans, end - start + 1); ansString = s.slice(start, end + 1); } } } return ans === Infinity ? "" : ansString; }
@piyushsaxena62433 жыл бұрын
after watching this playlist, i finally can say that i can solve almost every problem of sliding window, really this is the best explanation for sliding window technique. Thanks a lot
@aryans_space Жыл бұрын
A)Java soltuion for this video: as well as modified for leetcode in part B) public class minimum_window_substring { public static void main(String[] args) { String s = "timetopractice", t = "toc"; HashMap map=new HashMap(); for(int x=0;x
@nagpuri4390 Жыл бұрын
Bro can u pls help in the leetcode 1838 frequency of most frequent element question??? Using Aditya Sir approach
@pratiksonawane10762 жыл бұрын
Bhaiya aapki puri playlist dekhi. Best playlist on youtube for sliding window technique👌. Voting for backtracking series
@manavshah74503 жыл бұрын
Placement season has started. Please upload videos on graphs and backtracking. And possibly add more videos on DP. Thanks!
@akankshasinha33522 жыл бұрын
Hi … please tell , how to build concept for rest of the linkedlist and trees kind of problem? Cz everything is not covered on this channel ! 🥺😔 gimme some ideas
@AvikNayak_2 жыл бұрын
@@akankshasinha3352 you can check out take U forward youtube channel.
@manavshah74502 жыл бұрын
@@akankshasinha3352 check out take u forward. And love babbars dsa cracker sheet.
@vineetjadhav17854 ай бұрын
Here is the most easy to understand solution, I hereby conclude that I have completed this series and I am confident that I can identify and tackle the sliding window problems. Thanks Aditya Bhaiya ur teaching gave mine lost confidence back 🔥🔥❤❤ Code: class Solution { public: string minWindow(string s, string t) { unordered_map mp; for (char c : t) mp[c]++; int count = t.size(); int i = 0, j = 0; int ans = INT_MAX; int start = 0; while (j < s.size()) { if (mp[s[j]] > 0) count--; mp[s[j]]--; j++; while (count == 0) { if (j - i < ans) { ans = j - i; start = i; } mp[s[i]]++; if (mp[s[i]] > 0) count++; i++; } } if (ans == INT_MAX) return ""; return s.substr(start, ans); } };
@ewananmo24043 жыл бұрын
This has been an awesome series. Thanks a lot! Please cover more topics!
@rafiqn26753 жыл бұрын
Bhai kaha gaye the yaar... I just waited, waited and again I waited...
@siddhantsrivastava40483 жыл бұрын
Aditya shocked to see your face on recommended video😮😮 Good Job! SSMV ka naam roshan kar diya👍
Why you have checked the first value before the while loop(j
@curiossoul3 жыл бұрын
@@kanishkraj5640 i guess coz he is incrementing j bfr use in while loop, either move it to end of if block or start j with -1 to avoid it
@akankshasinha33522 жыл бұрын
Hi … please tell , how to build concept for rest of the linkedlist and trees kind of problem? Cz everything is not covered on this channel ! 🥺😔 gimme some ideas
@prathikmishra9779 ай бұрын
completed the whole playlist sir thankyou for such an effort of yours to explain this topic in such depth.
@deepakgurjar37462 жыл бұрын
Finally i Completed the whole playlists of the "appar gyan bhandar".......thanks thanks a lot*infinity Sir❤❤❤❤
@AmitSingh-nf2fz3 жыл бұрын
Sir please make videos on Back-Tracking and Graph !!! It will be very helpful for us who cannot afford such quality and expensive courses on other plateform. Keep up the good work sir!!!😇
@freshcontent37293 жыл бұрын
I'm also from MANIT CSE. Please please make a series on Trees and graphs. Much needed. Placement season is approaching.
@akankshasinha33522 жыл бұрын
Hi … please tell , how to build concept for rest of the linkedlist and trees kind of problem? Cz everything is not covered on this channel ! 🥺😔 gimme some ideas
@akshatmahajan26922 жыл бұрын
@@akankshasinha3352 You can check other channels related to coding as Leadcode by fraz and pepcoding(they have great playlists regarding different problems)
@hrithikkumar96482 жыл бұрын
@@akankshasinha3352 first of all see mycodeschool DSA playlist make notes then all playlist of Aditya Verma starting from heap, stacks, sliding window, binary search, recursion except dp .....and make sure to make notes of all these topics. Then watch striver recursion playlist and dp playlist and make notes . Then solve striver sde sheet of 180 question it might be difficult for uhh to solve every problems by own so try to see video solution.....nd I guarantee this is enough for anybody to get good placement nd for girls it is enough to get very good placement ☕☕🌚
@@prathamrajbhattnit-allahab4108 haan Bhai notes h thik thak bane hue bass mei jada decorated nhi krta hu notes I mean only use one pen ...aur concept pakda aur code rough type se likh diya ache se samajh mei aa jayega kisiko v mere notes 👍
@sameerchoudhary85903 жыл бұрын
The most awaited video of the most amazing teacher.
@sameerchoudhary85903 жыл бұрын
Bas ab ek hi cheez bachi hai zindagi me aur wo hai aapke charan sparsh karna.
@TheAdityaVerma3 жыл бұрын
Arreyy Nhi bhai, hmara aashirvaad aese hi sath h tumhare 🖐😬😬
@sameerchoudhary85903 жыл бұрын
Thank you so much for all this hard work sir, coding has never been this easy.
@AyushSharma-ww6vd3 жыл бұрын
Completely agree brother. I am so fortunate ki mujhe ye channel Mila.
@jayantsharma26693 жыл бұрын
I am following your DP playlist. I have seen comments of your every video, Everybody request you to make trees & graph tutorial. These topics are tougher to understand? If yes then I am also requesting you to make videos on them. Thanks
@tanmoymazumdar93543 жыл бұрын
Sir what happened to you.Hope you are kepping well the last video was uploaded 4 months ago we really want your help many are eagerly waiting for your videos. Please come back soon.
@rajshreegupta44543 жыл бұрын
Sir your way of teaching is really magical. Even hard questions of leetcode seem easy. This and upcoming generations are really blessed to have your lectures. Sir just a request please make graph also easy. You can make any topic a cakewalk.
@b_01_aditidonode4310 ай бұрын
thanks sir!! you explained the sliding window concept in amazing depth , amazing playlist
@Rohangamin5179 ай бұрын
This playlist of sliding window is like God gifted for everyone😊😊😊
@surendharv7952 жыл бұрын
Sir , My friend requested ur channel. I am a non Hindhi speaker. But somewhat I can understand ur video....It will be more better if u add subtitiles....Autogenerating Subtitles are not good.Thank you for the great content .
@sarankumar1652 жыл бұрын
*C++ Implementation* : string minWindow(string s, string t) { //declare window variables int i=0,j=0; int len=INT_MAX; //to store the length of minimum window int startIdx = 0; string result;//finally return s.substr(startIdx,len) //create freq. map unordered_map mp; for(int i=0 ; i
@akankshasinha33522 жыл бұрын
Hi … please tell , how to build concept for rest of the linkedlist and trees kind of problem? Cz everything is not covered on this channel ! 🥺😔 gimme some ideas
@azhar74722 жыл бұрын
Nice
@misterdi7238 Жыл бұрын
thank you so much bhai ...
@sarvagyaiitmadras87273 жыл бұрын
Thnx bro for not showing us the exact code but only explaining the logic , As, after doing the code without error after using with Video's logic, Is great feeling :)
@SUMITKUMAR-rt5bs3 жыл бұрын
Hey brother, can you provide your code?? My code is not working .
@TuringTested01 Жыл бұрын
doing MTECH in iit doesnt count so remove that iit madras from your profile name
@bruh-moment-21 Жыл бұрын
@@TuringTested01 It counts very well.
@satya_k2 жыл бұрын
Thank you Aditya Verma, really thank you! I completed the whole sliding window algo series, and I'm able to solve almost any kind of problem related to sliding window. Great series indeed. For those of you having difficulty writing the code for this, I wrote one to help you: //This function returns the smallest window(string) string smallestWindow (string s, string t) { // I really loved solving this problem - Love you Aditya Verma - You are a gem unordered_mapmap; unordered_mapans; //map to store the size and initial index of answer window for(auto x : t) map[x]++; int i = 0, j = 0, count = map.size(), minsize = INT_MAX, n = s.size(); bool flag = true; while(j
@debbh2742 жыл бұрын
Very nice video. Clarity of your thought process is awesome.
@cherish6893 жыл бұрын
Please continue uploading videos seriously u teach very well and it is very much understandable
@rishabhgupta9846 Жыл бұрын
After listening problem explanation able to solve by myself ,thank you for the series bhai
@parikshitsinghrathore61302 жыл бұрын
If you want to find the smallest string: string minWindow(string s, string t) { int starti=0; int endi=-1; int slen = s.length(); int tlen = t.length(); unordered_map mp; for(int i=0;i
@RohitKumar-cv7qb Жыл бұрын
stucked at an edge case in gfg
@vishalsethi40243 жыл бұрын
Great dedication "Likh hi deta hu"!!!
@ShubhamKumar-wj3fu3 жыл бұрын
Sir please complete the DP series. There is no content comparable to yours.
@googleit2490 Жыл бұрын
Great Explanation :) Coded after watching the video with a wrong attempt... Sep'27, 2023 11:10 pm
@gyan26642 жыл бұрын
I am glad previous approach provided help me to solve this problem , without looking at this videos
@amansinghgautam91893 жыл бұрын
Bhiya poora graph aur tree pe daalo videos plz. Btw aapka dp seris bhut mast tha😊😊😊😊😊. Bhiya dp ka playlist mein kuch missing h kyaa?? Yaa complete h woh?
@abhinavshukla64183 жыл бұрын
misiing he
@ruchitachandel23482 жыл бұрын
Your videos are so amazing. Please make a playlist of system design. we don't see any good system design videos especially in hindi.
@kms83203 жыл бұрын
Sir please make a dedicated series on backtracking, it is really needed.
@ayush45652 жыл бұрын
SIR, Ye toh Gold hai👏👏👏👏
@ShivaM-wg9qc4 ай бұрын
C++ Code for the explanation and also made the addition for LC Question as it needs us to return the actual substring : my solution is not the most optimal but this is what i came up with based on my current understanding. string minSubstrWindow(string s, string t) { if(t.length()>s.length()) { return ""; } int res = INT_MAX; // we calc the freq of each char in the map unordered_map map; unordered_map mapS; for(int i=0; i
@ShivaM-wg9qc4 ай бұрын
idea behind returning string as out answer : we use an ans variable since we know we are trying to find the smallest substring we can use that to our advantage and use the minimum window size. So whenever after changing the count to 1 we check if our stored ans length is > then the window if yes than store the string in the window as our answer
@brownwolf053 жыл бұрын
Please make playlist for backtracking and queue ds
@vinitverma17419 ай бұрын
Very Very good explanation
@clash-of-coding Жыл бұрын
Hello sir, you are the best teacher, what is next series.....I want sorting series.
@deepakbhallavi1612 Жыл бұрын
Thank you so much bhaiya ❤️ Now I am able to solve LeetCode medium problems based on sliding window 💯✅
@amanpreetsinghsetia15243 жыл бұрын
God of Dp is back🙌🏻🤩
@funnyhilarious123Ай бұрын
solved by my own, thank you for the concepts
@ashwanisingh8354 Жыл бұрын
C++ solution along with explanation to few condition I have taken into account string minWindow(string s, string t) { // base case if length of s in smaller than j if(s.size() < t.size()) return ""; // initialize the map to store character ocurring in t along with their count unordered_map map; for (char c : t) map[c]++; // define i and j and n = s.size() along with count int i = 0; int j = 0; int count = map.size(); int n = s.size(); int minSize = INT_MAX; //I am using pair to store the index of smallest resultant substring pair res{-1,-1}; while( j < n){ if(map.find(s[j]) != map.end()){ map[s[j]]--; if(map[s[j]] == 0)count--; } cout
@manojg44513 жыл бұрын
Hi Aditya ,Please make more videos
@MukulBansal0763 жыл бұрын
Sir please make a playlist on backtracking!!
@chrisogonas9 ай бұрын
Very well illustrated! Thanks
@mohit6215 Жыл бұрын
Aditya verma: "It's show time 😊"
@anirudhkumarchaudhary56813 жыл бұрын
Bhaiya graph ki series bhi upload kr do please 🙏
@NishantKumar-hu7dq3 жыл бұрын
Bhaiya youtube channel ka password bhul gye h kya??
@devsatendrasingh90902 жыл бұрын
// Idea behind iterating Given String length can thought as : // 1) Iterate thru string S till the count [map size from String T characters] variable reaches to 0. // 2) Once counter is 0, try to move the start(i) pointer towards end(0) pointer to minimize the length of the found substring. If character at start pointer matches with string T increment the count variable. Loop thru till count variable is 0. // if(s == null || s.length() < t.length() || s.length() == 0){ // return ""; // } int i=0; int j=0; String ans=""; int minSizeOfSubstring=Integer.MAX_VALUE; HashMapmap=new HashMap(); for(int m=0;m0 char chI=s.charAt(i); if(!map.containsKey(chI)){ i++; } else { map.put(chI,map.get(chI)+1); if(map.get(chI)>0){ count++; } i++; } // OTMTA or TMTA me compare karna hai if(count==0){ if(minSizeOfSubstring>j-i+1){ ans=s.substring(i,j+1); minSizeOfSubstring=j-i+1; } } } } j++; } return ans;
@yadavprakesh0033 жыл бұрын
Sir please make a graph series
@sushilsingh96322 жыл бұрын
Bhaiya other data structure and Algorithm me bhi videos bnaiye plz😌... The way you explain the approach of problems can't be found anywhere else🥰.
@JitendraKumar-ti6yd2 жыл бұрын
Thanks Aaditya bhai!! Completed DP and SLiding window playlist! Can you please upload video related to Backtracking and greedy algo
@shreyaskumarsharma59082 жыл бұрын
I think this code works in case when length of the minimum substring is to be returned : - int Solution(string s, string p) { int n = s.length(); int m = p.length(); int i = 0, j = 0; int Count = INT_MAX; int l = INT_MAX; unordered_map freq; for (int i = 0; i < m; i++) freq[p[i]]++; Count = freq.size(); if (m < n) { while (j < n) { if (freq.find(s[j]) != freq.end()) { freq[s[j]]--; if (freq[s[j]] == 0) Count--; } if (Count > 0) j++; if (Count == 0) { l = min(l, j - i + 1); while (Count == 0 && i
In this video condition is explained but "what to compare the condition to?" is not well explained, I tried "if count > 0: j++" and "else if count == 0: ...result and slide window". I then tried another approach. Below is the Python3 code for another approach: S = list("ADOBECODEBANC") T = list("ABC") freqT = {} for c in T: freqT[c] = freqT.get(c, 0) + 1 i = 0 j = 0 m = len(S) n = len(T) freqS = {} output = [] matchCount = 0 while i < m: # Acquire while i < m and matchCount < n: c = S[i] freqS[c] = freqS.get(c, 0) + 1 if freqS.get(c, 0)
@darshankubavat17643 жыл бұрын
Bro please can you make a playlist for the Greedy algorithm, there are not many playlists for greedy and if you teach us then it would be great for us.
@codetochange82 жыл бұрын
Sliding Window Completed 💯..Thank You Aditya Bhaiya 🙏🙏...
@parvahuja7618 Жыл бұрын
thankyou bhai saari video dekhi maza aaya
@kanhav033 жыл бұрын
I think it will also consider "CTO" as a minimum string when we are given "TOC" Because of the map that we used
@HimanshuSharma-cm8hi2 жыл бұрын
@MineCognito striver
@alienx23673 жыл бұрын
Are Verma Ji Underground Chale Gaye kya app
@tanaysingh5348 Жыл бұрын
can't thank you enough, had fun sliding through the playlist
@itz_me_imraan023 жыл бұрын
Your videos are too good.... Plz cover topics like segement trees, graphs, backtracking
@no-body72863 жыл бұрын
sir please continue this series , if you want we can rise fund for you ! in crowd funding
@suyashshukla66572 жыл бұрын
flipkart mein hai vo , fund raise karega
@preetambal74433 жыл бұрын
loved this video..will share your videos with all my friends..Top work..keep it up!
@pranjalgupta94273 жыл бұрын
Bhai ittne din baad.. Kaha chale gaye thee bhai?? Aapka video ka hum kabse wait kar rahe thee 😀😀
@Realमहात्मागांधी3 жыл бұрын
As much u find time make more video for ours it reqst 2u please🙏
@TheAdityaVerma3 жыл бұрын
Yaar job k sath manage krna thoda mushkil ho jata hai :( I hope you guys understand.
@rafiqn26753 жыл бұрын
@@TheAdityaVerma per bhai... Ab se thoda regularly upload karo please A placement time hai tho... Bahut help hogi... Hamari
@prateekvarshney22803 жыл бұрын
@@TheAdityaVerma bhai trees and graphs start karoo 🙏🙏
@SarthakKumar2 жыл бұрын
New videos ka wait kab khatam hoga sir!!!! Biggest Suspense of all time for us😅