Find All Anagrams in a String | Leetcode 438 | Array
Вставка
- Опубліковано 19 жов 2024
- Time Complexity : O(n*26) ~ O(n)
Space Complexity : O(1)
Problem Link : leetcode.com/p...
C++ Code Link : github.com/Ayu...
Please like, share and subscribe if you found the video useful. Feel free to ask in comments section if you have any doubts. :)
#DataStructuresAndAlgorithms
#LoveBabbarDSASheet
#interviewpreparation
Find All Anagrams in a String solution
Find All Anagrams in a String Leetcode
Find All Anagrams in a String C++
Find All Anagrams in a String Java
Find All Anagrams in a String Python
🔥🔥🔥🔥👇👇👇
Join telegram channel for more updates on placement preparation : t.me/AyushiSha...
Checkout the series: 🔥🔥🔥
👉Interview Experiences : • Interview Experiences
👉 Array: • Arrays
👉 Linked List : • Linked List
👉 Heap : • Heap
👉 Recursion : • Recursion
👉 Stack and Queue : • Stack And Queue
👉 Greedy : • Greedy
👉 Dynamic Programming : • Dynamic Programming
👉 Leetcode contests : • Leetcode contests
👉 Leetcode June Challenge : • Leetcode June Challenge
👉 Leetcode July Challenge : • Leetcode July Challenge
LIKE | SHARE | SUBSCRIBE 🔥🔥😊
Great Explanation 💯🔥
Earlier I thought of finding permutations of p's and storing in hashmap and then just iterating over the anagram string..
Here will the Space complexity be O(1) !!
I meant we are using an answer vector na so that way ...?
Those two freq and window vector have constant space but the ans vector!!
yes, but the output vector or string we have, that we do not consider as extra space :), because that is anyway needed, any extra data structure we use for solution, that we consider in space complexity :)
@@AyushiSharmaDSA ohh yaa
Awesome, very clear explanation with examples..
Thank you Manish, glad it was helpful :)
Thanks for that awesome explaination!! 🤗
Welcome Shreya, glad it was helpful :)
I liked your consistency Sis 👏. Started doing daily Leetcode challenge problem bcoz of u. You are truly an inspiration to me...😊
Thank you Kolli, means a lot :)
another elegant solution, nice as always. 😀
Thank you! 🤗
Great explaination di. Got the approach
Thanks :)
Solution was great
Subscribed 💯
Thank you Vibhor 😊
Explanation was just perfect...!!!👍
Thank you Siraj, glad it was helpful :)
you are gem i don;t have words to thank you
Thank you Shaily, glad it was helpful :)
Playlist me apne sare videos dalo topic wise bohot help hogi
Hi, sure :)
Thank you di
Welcome Ishaan, glad it was helpful :)
if u r comparing vectors in each step its complexity would be o(k) so overall complexity will be o(n*k).also the space complexity is not constant its o(n).because u r using the extra array
Hi , size of vector is 26 and space complexity will be constant as vector size will be 26
@@AyushiSharmaDSA u r right size is small so it wont matter here
superb explanation 🙌🙌🥳🥳di can u plz make a video on sum of two arrays
Sure Parth :) can you share the problem link
OP Solution
Thank you Saurabh :)
Which colllage
?
Please solve Set Matrix Zeroes leetcode problem
Sure :)
How many questions to do per topic??
Hi Vishnu, nothing as such, just start with easy practice around(10-15) and then you can do medium problems.
@@AyushiSharmaDSA as a beginner, can I start watching your arrays vedio
@@VishnuYadav-so5yv no, I would suggest first get familiar with every data structure like if you want to use hashmap then which library you will use, like that. Then when you know each and every data structure, you can start practicing different problems :)
@@AyushiSharmaDSA okk thank you so much for replying😊
Live class kab se start hogi?
Hi Reena, I actually was thinking that I'll make videos and then we can have live doubt sessions
@@AyushiSharmaDSA Okk 👍
I need it in java
🙃java sometimes
sure😅
Last line not cleared
i -len+1
Dry run the code bro ,you will get it...
Since you have to return the starting index that's why we are substracting the Length bcz in loop we are iterating after the window size
Yes Pratyush, dry run once and let me know if it's not clear then :)
can any please check my code it giving 0 as answer always
int search(string pat, string txt) {
int p[26]={0};int t[26]={0};
const char *s = pat.c_str(); int len=0;
while (*s)
{
p[*s-'a']++;
s++; len++;
}
int count=0; int flag=1;
const char *x = txt.c_str(); int lent=0; const char *first = txt.c_str();
while(*x)
{
t[*x-'a']++;
if(lent>=len) { flag=1;
for(int row=0;row
New photo mast ha 😄
😂😅😅