Advertisement
lazar955

Untitled

Oct 22nd, 2023
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.35 KB | None | 0 0
  1. func groupAnagrams(strs []string) [][]string {
  2.     res:=map[[26]int][]string{}
  3.  
  4.     for _,s:=range strs {
  5.         count:=[26]int{}
  6.  
  7.         for _,c:=range s{
  8.             count[c-'a'] +=1
  9.         }
  10.         res[count]=append(res[count],s)
  11.     }
  12.  
  13.     frs:=[][]string{}
  14.     for _,v:=range res {
  15.         frs = append(frs,v)
  16.     }
  17.     return frs
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement