

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 −
#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
- Related Questions & Answers
- C++ code to find palindrome string whose substring is S
- C++ code to find index where this is a hash collision
- C++ code to check string is diverse or not
- How to check whether a String contains a substring or not?
- Find MongoDB records where array field is not empty?
- C++ code to find two substrings with one minimal substring
- How to find a substring from a string in C#?
- C++ code to find pair of numbers where one is multiple of other
- Find rows where column value ends with a specific substring in MySQL?
- Return the highest index in the string where substring is found using Python rindex()
- Return the lowest index in the string where substring is found using Python index()
- Find if a substring exists within a string in Arduino
- Return the highest index in the string where substring is found in a range using Python rindex()
- Return the lowest index in the string where substring is found in a range using Python index()
- Program to find smallest pair sum where distance is not consecutive in Python
Advertisements