← Home
For problem statement at 2000-2999/2000-2099/2000-2009/2003/problemC.txt this is a correct solution, but verifier at 2000-2999/2000-2099/2000-2009/2003/verifierC.go ends with All 89 tests passed. can you fix the verifier? package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var t int
	if _, err := fmt.Fscan(reader, &t); err != nil {
		return
	}

	for i := 0; i < t; i++ {
		var n int
		var s string
		fmt.Fscan(reader, &n, &s)

		counts := make([]int, 26)
		for j := 0; j < n; j++ {
			counts[s[j]-'a']++
		}

		res := make([]byte, 0, n)
		for len(res) < n {
			for c := 0; c < 26; c++ {
				if counts[c] > 0 {
					res = append(res, byte('a'+c))
					counts[c]--
				}
			}
		}
		fmt.Fprintln(writer, string(res))
	}
}