Language: C++

#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		vector<UL> ans; ans.assign(26, 0);
		vector<UL> prev; prev.assign(26, (UL)-1);
		string S; cin >> S;
		rep(i, S.size()) {
			UL p = S[i] - 'a';
			if (prev[p] == (UL)-1) {
				ans[p] = max(ans[p], i);
			}
			else {
				ans[p] = max(ans[p], (UL)(i - prev[p] - 1));
			}
			prev[p] = i;
		}
		UL ans2 = 10000000;
		rep(i, 26) {
			if (prev[i] == (UL)-1) continue;
			ans[i] = max(ans[i], S.size() - 1 - prev[i]);
			ans2 = min(ans2, ans[i]);
		}
		cout << ans2 << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Compiler output:
a.cc: In member function 'void Problem::Solve()':
a.cc:28:37: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<unsigned int>, unsigned int>::value_type&, std::__cxx11::basic_string<char>::size_type)'
   28 |                         ans[i] = max(ans[i], S.size() - 1 - prev[i]);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:28:37: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   28 |                         ans[i] = max(ans[i], S.size() - 1 - prev[i]);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:28:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
   28 |                         ans[i] = max(ans[i], S.size() - 1 - prev[i]);
      |                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~