Last active
May 3, 2020 19:25
-
-
Save PatrickWalker/284ebdb42ed8f0e654da741be57c2e47 to your computer and use it in GitHub Desktop.
String to Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func convertStringToMap(in string) map[string]int32 { | |
rA := []rune(in) | |
strMap := map[string]int32{} | |
for _, v := range rA { | |
if count,ok := strMap[string(v)]; ok { | |
strMap[string(v)]=count+1 | |
}else{ | |
strMap[string(v)]=1 | |
} | |
} | |
return strMap | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment