← Home
For problem statement at 1000-1999/1200-1299/1200-1209/1208/problemB.txt this is a correct solution, but verifier at 1000-1999/1200-1299/1200-1209/1208/verifierB.go ends with All tests passed can you fix the verifier? ```go
package main

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

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

	var n int
	fmt.Fscan(reader, &n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &a[i])
	}

	suffixCounts := make(map[int]int)
	right := n
	// Find the longest valid suffix a[right...n-1]
	for right > 0 {
		if suffixCounts[a[right-1]] > 0 {
			break
		}
		suffixCounts[a[right-1]]++
		right--
	}

	// Initial answer corresponds to keeping only the suffix a[right...n-1]
	// The removed subsegment is a[0...right-1], length = right
	minRemoved := right

	prefixCounts := make(map[int]bool)

	// Iterate through all possible valid prefixes a[0...i]
	for i := 0; i < n; i++ {
		val := a[i]
		if prefixCounts[val] {
			break
		}
		prefixCounts[val] = true

		// Shrink the suffix from the left until it's disjoint from the current prefix
		// and also specifically does not contain the value a[i]
		for right < n && suffixCounts[val] > 0 {
			suffixCounts[a[right]]--
			right++
		}

		// Calculate the size of the removed subsegment between prefix end (i) and suffix start (right)
		// Removed indices: i+1 ... right-1
		// Length = right - (i + 1)
		currentRemoved := right - (i + 1)
		if currentRemoved < minRemoved {
			minRemoved = currentRemoved
		}
	}

	fmt.Fprintln(writer, minRemoved)
}
```