please reply sir,iam learning python and using in cpp will it possible because iam afraid so many are desupproting me like python is too slow you may not work in icpc and in c++ has so many libaries to solve problems where not in python or not idont know? @@GregHogg
Master Data Structures & Algorithms For FREE at AlgoMap.io!
Do you recommend using Counter in an actual interview?
I think maybe not. Because the interviewer wants to see your ability to solve a problem step by step.
return sorted(s) == sorted(t) 🗿
The time complexity matters and this one is slow
Another Solution :
def isAnagram(self, s, t):
return sorted(s) == sorted(t)
It works, but the time complexity is a little higher, O(nlogn)
I used a similar approach to what I did in Ransom Note.
for i in set(s):
if s.count(i) != t.count(i) or len(s) != len(t):
return False
return True
Is the time complexity really O(n)? I ask it because the Counter need run through list to creat the dictionary and sort the last one.
This is an awesome series keep it up 👍🏾
Thank you! :)
please reply sir,iam learning python and using in cpp will it possible because iam afraid so many are desupproting me like python is too slow you may not work in icpc and in c++ has so many libaries to solve problems where not in python or not idont know? @@GregHogg
nice short solution, thanks for sharing
thanks for sharing this
Thank you :)
Happy end of year
You too Christian!
great