# C++ code to find string where trygub is not a substring

C++Server Side ProgrammingProgramming

Suppose we have a string S with n lowercase English letters. We have to reorder the characters in S, so that "trygub" is not a subsequence of the resulting string.

So, if the input is like S = "pintontrygubabc", then the output will be "abbcginnoprttuy".

## Steps

To solve this, we will follow these steps −

sort the array S
return S

## Example

Let us see the following implementation to get better understanding −

#include <bits/stdc++.h>
using namespace std;
string solve(string S){
sort(S.begin(), S.end());
return S;
}
int main(){
string S = "pintontrygubabc";
cout << solve(S) << endl;
}

## Input

"pintontrygubabc"

## Output

abbcginnoprttuy
Updated on 15-Mar-2022 06:08:27