---
# System prepended metadata

title: Untitled

---

```go=package main

import (
	"fmt"
	"strings"
	"unicode"
)

func main() {
	s := "AcZCbaBz"
	fmt.Println(helper(s, 0, len(s)))
}

func helper(s string, l, r int) int {
	if l >= r {
		return -1
	}

	m := make(map[string]int)

	for i := l; i < r; i++ {
		c := s[i]
		if _, ok := m[string(c)]; !ok {
			m[string(c)] = 1
		} else {
			m[string(c)] += 1
		}
	}

	for i := l; i < r; i++ {
		c := rune(s[i])
		uS := ""
		if unicode.IsUpper(c) {
			uS = strings.ToLower(string(s[i]))
		} else {
			uS = strings.ToUpper(string(s[i]))
		}

		if _, ok := m[uS]; !ok {
			return max(helper(s, l, i), helper(s, i+1, r))
		}
	}

	return r - l
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

```