Given two strings s1 and s2, the task is to find whether the two string contain the same characters that occur in the same order. For example: string “Geeks” and string “Geks” contain the same characters in same order.
Input: s1 = “Geeks”, s2 = “Geks”
Input: s1 = “Arnab”, s2 = “Andrew”
Approach: We have two strings now we have to check whether the strings contain the same characters in the same order. So we will replace the contiguous similar element with a single element i.e. if we have “eee”, we will replace it with a single “e”. Now we will check that both the strings are equal or not. If equal then print Yes else No.
Below is the implementation of the above approach:
- Print common characters of two Strings in alphabetical order
- Python code to print common characters of two Strings in alphabetical order
- Check if lowercase and uppercase characters are in same order
- Check if the characters of a given string are in alphabetical order
- Check if string follows order of characters defined by a pattern or not | Set 1
- Check if string follows order of characters defined by a pattern or not | Set 2
- Check if string follows order of characters defined by a pattern or not | Set 3
- Check whether two strings can be made equal by copying their characters with the adjacent ones
- Test Case Generation | Set 2 ( Random Characters, Strings and Arrays of Random Strings)
- Print characters in decreasing order of frequency
- Print characters having odd frequencies in order of occurrence
- Print characters and their frequencies in order of occurrence
- Print characters having even frequencies in order of occurrence
- Meta Strings (Check if two strings can become same after a swap in one string)
- Print all distinct characters of a string in order (3 Methods)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.