Python C++ hash table速解Leetcode 49 Group Anagrams
s is anagram of t ⟺ freq(s)=freq(t) ⟺ sorted(s)=sorted(t)
In other words, s is a permutation of t.
-----
There are many ways to solve Leetcode's old problem 49. Group Anagrams, but once you figure out that anagrams are arrangements of the same set of letters, a simple and quick answer becomes available.
[codes on Leetcode]https://leetcode.com/problems/group-anagrams/solutions/4683930/4-approaches-freq-count-sort-compression-12ms-beats-99-82/
[Leetcode playList]https://www.youtube.com/watch?v=FrnktWsWFeQ&list=PLYRlUBnWnd5IdDHk2BjqXwesydU17z_xk
[Dynamic Programming Playlist]https://www.youtube.com/watch?v=30yq3fmE6E8&list=PLYRlUBnWnd5K_XYUesV9oc6M9ONXII61T
沒有留言:
張貼留言