I alluded to approaches like this at 6:00 (and why I avoided them). That said, I don't think the variable names "ts" and "ss" add any clarity, and your boolean logic can be simplified. So if you were intent on comparing Counter instances using ==, I'd do it like this: return Counter(s) == Counter(t)