Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define de(x) cout<<#x<<"="<<x<<endl
const int N=2e5+7;
char s[N];
int a[27];
int dj[N];
bool gman(){
	for(int i=0;i<26;i++)
		if(a[i]==0)return false;
	return true;
}
int next[N][27];
int now[27];
int main(){
    scanf("%s",&s);
    int len=strlen(s);
    int no=0;
    for(int i=len-1;i>=0;i--){
        dj[i]=no;
        a[s[i]-'a']++;
        now[s[i]-'a']=i;
        for(int j=0;j<26;j++){
            next[i][j]=now[j];
        }

        if(gman()){
            memset(a,0,sizeof(a));
            no++;
        }
    }
    for(int i=0;i<26;i++){
        if(a[i]==0){
            printf("%c",i+'a');break;
        }
    }
    if(no==0)return 0;
    int tmp;
    for(int i=0;i<26;i++){
        if(a[i]==0 ){
            tmp=now[i];break;
        }
    }
    for(int i=no-2;i>=0;i--){
        for(int j=0;j<26;j++){
            if( dj[tmp]-1== dj[ next[tmp][j] ] ){
                printf("%c",'a'+j);
                tmp=next[tmp][j];
            }
        }
    }
    for(int i=0;i<26;i++)
    if( next[tmp][i]==0){
        printf("%c",i+'a');
        return 0;
    }


}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: error: reference to 'next' is ambiguous
   25 |             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:14:5: note:                 'int next [200007][27]'
   14 | int next[N][27];
      |     ^~~~
a.cc:47:33: error: reference to 'next' is ambiguous
   47 |             if( dj[tmp]-1== dj[ 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:14:5: note:                 'int next [200007][27]'
   14 | int next[N][27];
      |     ^~~~
a.cc:49:21: error: reference to 'next' is ambiguous
   49 |                 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:14:5: note:                 'int next [200007][27]'
   14 | int next[N][27];
      |     ^~~~
a.cc:54:9: error: reference to 'next' is ambiguous
   54 |     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:14:5: note:                 'int next [200007][27]'
   14 | int next[N][27];
      |     ^~~~