Find All Anagrams in a String-(Amazon, Microsoft, Flipkart):Explanation ➕ Live Coding 🧑🏻💻👩🏻💻
HTML-код
- Опубликовано: 16 сен 2024
- This is the 2nd video on Sliding Window Playlist .
We will be going through the Sliding Window in the easiest way possible and will make it one of the easiest topics.
Today, we will do our very first Qn 'Find All Anagrams in a String'
Problem Name : Find All Anagrams in a String
Leetcode Link : leetcode.com/p...
GfG Link : practice.geeks...
My solutions on Github : github.com/MAZ...
Company Tags 😱🤯 : Amazon, Intuit, Microsoft, Flipkart
My GitHub Repo for interview preparation : github.com/MAZ...
Subscribe to my channel : / @codestorywithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
#coding #helpajobseeker #easyrecipes
#interviewpreparation #interview_ds_algo #hinglish
Most Underrated channel ever !!!
true that!
binge watching man.
You are awesome
amazing explanation bhaiya thank you
you gave the best explanation man.
reach++
Thank you so much 👍🏻😇
Awesome explanation!
Thank you so much ❤️🙏
Nice explanation
Same sliding window approach using unordered_map:-
class Solution {
public:
vector findAnagrams(string s, string p) {
unordered_map mp;
for(int i=0;i
Hi Bhaiya, bhot hi clear solution tha kya ek video manacher's algorithm pe bnaoge kya. YT pe tutorials pade h but aapse achha koi ni smjha skta so please wo ek request thi
Java Code:-
class Solution {
boolean allzero(int[] counter){
for(int i=0;i
Understood.
def check(self,counter):
for i in counter:
if i!=0:
return 0
return 1
def findAnagrams(self, s: str, p: str) -> List[int]:
k=len(p)
ans=[]
counter=[0 for i in range(26)]
for i in p:
counter[ord(i)-ord('a')]+=1
i=0
for j in range(len(s)):
counter[ord(s[j])-ord('a')]-=1
while(j-i+1==k):
if self.check(counter):
ans.append(i)
counter[ord(s[i])-ord('a')]+=1
i+=1
return ans