Skip to content

Commit

Permalink
Add new solution for cw-indexed-capitaliztion
Browse files Browse the repository at this point in the history
  • Loading branch information
skosovsky committed Dec 14, 2023
1 parent 731e3e1 commit 19be986
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cw-indexed-capitaliztion/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"strings"
"unicode"
)

Expand Down Expand Up @@ -32,3 +33,14 @@ func Capitalize(st string, arr []int) string {

return string(newline)
}

func CapitalizeELegant(st string, arr []int) string {
res := strings.Split(st, "")
for _, v := range arr {
if v >= len(res) {
continue
}
res[v] = strings.ToUpper(res[v])
}
return strings.Join(res, "")
}

0 comments on commit 19be986

Please sign in to comment.