You are viewing a single comment's thread. Return to all comments →
What i love in python is the straightforward & clean approach:
sum([abs(s1.count(c) - s2.count(c)) for c in set(s1 + s2)])
and that's it! pure developer's pleasure! Of course it runs in O(N^2), so it's shortness over performance. will be a 3-liner to run in O(N)
Seems like cookies are disabled on this browser, please enable them to open this website
Making Anagrams
You are viewing a single comment's thread. Return to all comments →
What i love in python is the straightforward & clean approach:
and that's it! pure developer's pleasure! Of course it runs in O(N^2), so it's shortness over performance. will be a 3-liner to run in O(N)