Given string str. The task is to check if the string contains consecutive letters and each letter occurs exactly once.
Input: str = “fced”
The string contains ‘c’, ‘d’, ‘e’ and ‘f’ which are consecutive letters.
Input: str = “xyz”
Input: str = “abd”
The following steps can be followed to solve the problem:
- Sort the given string in ascending order.
- Check if s[i]-s[i-1]==1, for every index i from 1 to n-1.
- If the condition holds for every index, print “Yes”, else print “No”.
Below is the implementation of the above approach:
- Length of the longest substring with no consecutive same letters
- Check if a string has m consecutive 1's or 0's
- Check if a binary string contains consecutive same or not
- String containing first letter of every word in a given string with spaces
- Smallest Greater (than S) String of length K whose letters are subset of S
- Count of words whose i-th letter is either (i-1)-th, i-th, or (i+1)-th letter of given word
- First uppercase letter in a string (Iterative and Recursive)
- Get the first letter of each word in a string using regex in Java
- Number of positions where a letter can be inserted such that a string becomes palindrome
- Get K-th letter of the decoded string formed by repeating substrings
- Number of times the given string occurs in the array in the range [l, r]
- Maximum length prefix of one string that occurs as subsequence in another
- Number of permutations of a string in which all the occurrences of a given character occurs together
- Make palindromic string non-palindromic by rearranging its letters
- Remove consecutive vowels from string
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.