Challenge 08 - Check Permutations
👋 Welcome Gophers! In this Go challenge, you are going to be implementing a function that takes in two string
values and checks to see if they are permutations of one another.
Example
If I have 2 strings, “abc” and “cba”, when I pass these strings into the function, it should return true
as these two strings are permutations of each other.
Hints
You can iterate through all the characters in a string using the
range
keyword in a for loop
// prints out the position and the rune
for pos, char := range str1 {
fmt.Printf("%d: %c\n", pos, char)
}
Start off by building up a map of these rune
values to the number of occurrences in one for loop and then work from there.
Further Reading:
If you enjoyed this challenge, you may also enjoy some of these other challenges: