← Home
For problem statement at 0-999/700-799/790-799/794/problemC.txt this is a correct solution, but verifier at 0-999/700-799/790-799/794/verifierC.go ends with Test 2 failed
Input:kobh
dkob
Expected:bohk
Got:bohb


exit status 1 can you fix the verifier? ```go
package main

import (
	"fmt"
	"sort"
)

func main() {
	var s, t string
	fmt.Scan(&s)
	fmt.Scan(&t)

	n := len(s)

	// Sort Oleg's letters ascending (he wants lex smallest, so he'll place small letters at front, large letters at back)
	// Sort Igor's letters descending (he wants lex largest, so he'll place large letters at front, small letters at back)
	oleg := []byte(s)
	igor := []byte(t)

	sort.Slice(oleg, func(i, j int) bool { return oleg[i] < oleg[j] })
	sort.Slice(igor, func(i, j int) bool { return igor[i] > igor[j] })

	result := make([]byte, n)

	// We use two pointers: left (for placing at the front) and right (for placing at the back)
	left := 0
	right := n - 1

	olegLeft := 0
	olegRight := len(oleg) - 1
	igorLeft := 0
	igorRight := len(igor) - 1

	// Total moves: n moves, Oleg goes first
	// Oleg makes ceil(n/2) moves, Igor makes floor(n/2) moves
	// They alternate: Oleg, Igor, Oleg, Igor, ...

	for i := 0; i < n; i++ {
		if i%2 == 0 {
			// Oleg's turn - wants lex smallest
			// Strategy: if his best letter (smallest) is smaller than Igor's best letter (largest),
			// place it at the front (leftmost position)
			// Otherwise, place his largest letter at the back (rightmost position)
			// to minimize damage
			if oleg[olegLeft] < igor[igorLeft] {
				// Place smallest oleg letter at front
				result[left] = oleg[olegLeft]
				olegLeft++
				left++
			} else {
				// Place largest oleg letter at back
				result[right] = oleg[olegRight]
				olegRight--
				right--
			}
		} else {
			// Igor's turn - wants lex largest
			// Strategy: if his best letter (largest) is larger than Oleg's best letter (smallest),
			// place it at the front (leftmost position)
			// Otherwise, place his smallest letter at the back (rightmost position)
			if igor[igorLeft] > oleg[olegLeft] {
				// Place largest igor letter at front
				result[left] = igor[igorLeft]
				igorLeft++
				left++
			} else {
				// Place smallest igor letter at back
				result[right] = igor[igorRight]
				igorRight--
				right--
			}
		}
	}

	fmt.Println(string(result))
}
```