Re:Never fail a technical interview again
by xigoi on Saturday December 07, 2024 @05:52PM
(#42353476)
str1 = "a"
str2 = "ab"
Re:Never fail a technical interview again
by BeFlatXIII on Sunday December 08, 2024 @11:58AM
(#42358211)
Good catch.
Counter(str1) - Counter(str2) | Counter(str2) - Counter(str1)
That ought to work. I'd hope Python's caching doesn't recompute the Counter for long strings.
if not Counter(str1) - Counter(str2): # success, they are anagrams