Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C++ code to find string where trygub is not a substring
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 −
#includeusing namespace std; string solve(string S){ sort(S.begin(), S.end()); return S; } int main(){ string S = "pintontrygubabc"; cout Input
"pintontrygubabc"Output
abbcginnoprttuy
Advertisements
