For problem statement at 2000-2999/2000-2099/2040-2049/2047/problemB.txt this is a correct solution, but verifier at 2000-2999/2000-2099/2040-2049/2047/verifierB.go ends with test 2 case 1: suboptimal permutation count 2 (expected 1)
exit status 1 can you fix the verifier? package main
import (
"fmt"
)
func main() {
var t int
fmt.Scan(&t)
for i := 0; i < t; i++ {
var n int
var s string
fmt.Scan(&n, &s)
counts := make(map[rune]int)
for _, c := range s {
counts[c]++
}
maxC, minC := -1, 100
var maxChar, minChar rune
for c, count := range counts {
if count > maxC {
maxC = count
maxChar = c
}
if count < minC {
minC = count
minChar = c
}
}
res := []rune(s)
for j, c := range res {
if c == minChar {
res[j] = maxChar
break
}
}
fmt.Println(string(res))
}
}