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 charcters 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 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 3
- Check if string follows order of characters defined by a pattern or not | Set 2
- Test Case Generation | Set 2 ( Random Characters, Strings and Arrays of Random Strings)
- Print characters and their frequencies in order of occurrence
- Print characters having odd frequencies in order of occurrence
- Print all distinct characters of a string in order (3 Methods)
- Meta Strings (Check if two strings can become same after a swap in one string)
- Given a sorted dictionary of an alien language, find order of characters
- Common characters in n strings
- Find uncommon characters of the two strings
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.