func lengthOfLongestSubstring(s string) {
match := make(map[string]int)
var current string
current = s[0]
if match[current] == 1 {
///
}
}
Run Code Online (Sandbox Code Playgroud)
为什么我收到错误cannot use s[0] (type byte) as type string in assignment?据我所知很明显s是 type string,为什么访问一个字符会将它变成 type byte?
小智 8
func lengthOfLongestSubstring(s string) {
strArr:=[]rune(s)
fmt.Println(string(strArr[0]))
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7841 次 |
| 最近记录: |