← Home
For problem statement at 1000-1999/1600-1699/1660-1669/1666/problemD.txt this is a correct solution, but verifier at 1000-1999/1600-1699/1660-1669/1666/verifierD.go ends with All 5 tests passed. can you fix the verifier? package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	if !scanner.Scan() {
		return
	}

	for scanner.Scan() {
		s := scanner.Text()
		if !scanner.Scan() {
			break
		}
		t := scanner.Text()

		counts := make([]int, 26)
		for i := 0; i < len(t); i++ {
			counts[t[i]-'A']++
		}

		q := len(t) - 1
		possible := true
		for p := len(s) - 1; p >= 0; p-- {
			charS := s[p]
			if q >= 0 && charS == t[q] {
				counts[charS-'A']--
				q--
			} else if counts[charS-'A'] > 0 {
				possible = false
				break
			}
		}

		if possible && q < 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}