Given a string str of lowercase alphabets only. The task is to replace every character by some new character. The new character belongs to (small case only) Replacement of str[i] is determined by:
str[i] = Character obtained after traversing ascii(str[i]) no. of characters in ‘a-z’ repeatedly after str[i].
Input: str = “geeksforgeeks”
In the above case str = “geeksforgeeks”,
the ASCII value of ‘g’ is 103 therefore ‘g’ has been replaced by moving 103 times from ‘g’ in the desired range i.e., a-z.
Hence, character ‘g’ is replaced by ‘f’.
Similarly, the complete string “geeksforgeeks” becomes “fbbnddvbfbbnd”.
Input: str = “science”
- Traverse the string.
- For every i, find the character that needs to be replaced with str[i].
- Replace str[i] with that character.
Below is the implementation of above approach:
- Replace every character of string by character whose ASCII value is K times more than it
- Replace a character c1 with c2 and c2 with c1 in a string S
- Find a string such that every character is lexicographically greater than its immediate next character
- Map every character of one string to another such that all occurrences are mapped to the same character
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Count substrings that starts with character X and ends with character Y
- Longest Common Prefix using Character by Character Matching
- Shortest distance to every other character from given character
- Lexicographically smallest string formed by appending a character from first K characters of a string | Set 2
- Lexicographically smallest string formed by appending a character from the first K characters of a given string
- Find the character in first string that is present at minimum index in second string
- Queries to find the last non-repeating character in the sub-string of a given string
- Convert the string into palindrome string by changing only one character.
- Queries to find the first non-repeating character in the sub-string of a string
- Check whether the given character is in upper case, lower case or non alphabetic character
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.