I think you can remove the c1==c2 condition as it should already be included in the second condition. if c1 equals c2 means that both strings share the same set of chars and the same distribution of counts Thanks a lot for the videos, watched a couple and they were short but very clear and easy to understand
How do you come up with such a great ideas?! I appreciate it! Thank you Tim!
Wanted to share refactored version:
def closeStrings(self, word1: str, word2: str) -> bool:
hist1 = Counter(word1)
hist2 = Counter(word2)
hist3 = Counter(hist1.values())
hist4 = Counter(hist2.values())
return hist3 == hist4 and set(word1) == set(word2)
great explanation! thanks a lot for this!
I think you can remove the c1==c2 condition as it should already be included in the second condition. if c1 equals c2 means that both strings share the same set of chars and the same distribution of counts
Thanks a lot for the videos, watched a couple and they were short but very clear and easy to understand
was thinking the same thing as well :)
The first thing that comes to your mind is recursion. Every single time lol
Tell me about it!
thank you sir
Great explanation! Thanks!
great video 😎
Why did you do a list comprehension [v for v in c1.values()]? Is this not just the same as simply c1.values()?
Doh good point!
damn it sefficent as fuck