Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Hey,
Imagine
a = []int{1, 2, 5, 100}
ands = "abcdef"
soby
r := []rune(s)
we convert the input string to its runes (characters),so we have slice of characters in
r
, e.g.r[0]='a'
andr[1]='b'
and so on.Using
for _, v := range a {
iterate over indices e.g.1, 2, 5, 100
usingv
.here
if v >= 0 && v < len(r)
we make sure that indexv
is valid index inside the slice.Then we convert the rune to upper case and save it in place:
r[v] = unicode.ToUpper(r[v])
.So now
r = []rune{'a','B','C','d','e','F'}
.Finally convert to string:
return string(r)
.I hope this helps.