diff --git a/problems/1002.查找常用字符.md b/problems/1002.查找常用字符.md index 57fa7dae..8d81e3f8 100644 --- a/problems/1002.查找常用字符.md +++ b/problems/1002.查找常用字符.md @@ -327,37 +327,45 @@ var commonChars = function(words) { ### GO ```golang -func commonChars(words []string) []string { - length:=len(words) - fre:=make([][]int,0)//统计每个字符串的词频 - res:=make([]string,0) - //统计词频 - for i:=0;i 0 { + s := string('a' + i) // rune -> string + result = append(result, s) + hash[i]-- + } + } + + return result } -func min(a,b int)int{ - if a>b{ - return b - } - return a + +func min(a, b int) int { + if a < b { + return a + } + return b } ```