Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define IO ios::sync_with_stdio(false),cin.tie(0)
#define FIN freopen("D://code//in.txt", "r", stdin)
#define ppr(i,x,n) for(int i = x;i <= n;i++)
#define rpp(i,n,x) for(int i = n;i >= x;i--)
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

inline int read() {//读入挂
    int ret = 0, c, f = 1;
    for(c = getchar(); !(isdigit(c) || c == '-'); c = getchar());
    if(c == '-') f = -1, c = getchar();
    for(; isdigit(c); c = getchar()) ret = ret * 10 + c - '0';
    if(f < 0) ret = -ret;
    return ret;
}
int next[maxn][26];
int now[26],area[maxn];
int tot,tmp;
set<int >S;
int main()
{
	IO;
	tot = 0;
	string s;
	string ans;
	cin>>s;
	rpp(i,s.size()-1,0)
	{
		int gg = s[i] - 'a';
		S.insert(gg);
		area[i] = tot;
		if(S.size() == 26)
		{
			tot++;
			S.clear();
		}
	}
	if(tot == 0)
	{
		ppr(i,0,25)
		{
			if(S.count(i) == 0)
			{
				char minn= i+'a';
				cout<<minn<<endl;
				return 0;
			}
		}
	}
	rpp(i,s.size()-1,0)
	{
		ppr(j,0,25)
		{
			next[i][j] = now[j];
		}
		now[s[i] - 'a'] = i;
	}
	ppr(i,0,25)
	{
		if(S.count(i) == 0)
		{
			ans += (i + 'a');
			tmp = now[i];
			break;
		}
		
	}
	ppr(i,1,tot)
	{
		ppr(j,0,25)
		{
			if(area[next[tmp][j]] == area[tmp]-1)
			{
				char minn = j + 'a';
				ans += minn;
				tmp = next[tmp][j];
				break;
			}
		}
	}
	ppr(i,0,25)
	{
		if(next[tmp][i] == 0)
		{
			char minn = i + 'a';
			ans += minn;
			break;
		}
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:25: error: reference to 'next' is ambiguous
   62 |                         next[i][j] = now[j];
      |                         ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:5: note:                 'int next [200010][26]'
   24 | int next[maxn][26];
      |     ^~~~
a.cc:80:33: error: reference to 'next' is ambiguous
   80 |                         if(area[next[tmp][j]] == area[tmp]-1)
      |                                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:5: note:                 'int next [200010][26]'
   24 | int next[maxn][26];
      |     ^~~~
a.cc:84:39: error: reference to 'next' is ambiguous
   84 |                                 tmp = next[tmp][j];
      |                                       ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:5: note:                 'int next [200010][26]'
   24 | int next[maxn][26];
      |     ^~~~
a.cc:91:20: error: reference to 'next' is ambiguous
   91 |                 if(next[tmp][i] == 0)
      |                    ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:5: note:                 'int next [200010][26]'
   24 | int next[maxn][26];
      |     ^~~~