Given a string str consisting of lowercase English alphabets. The task is to change each character of the string with the next letter (in a circular fashion) key in the keyboard. For example, ‘a’ gets replaced with ‘s’, ‘b’ gets replaced with ‘n’, ….., ‘l’ gets replaced with ‘z’, ….., ‘m’ gets replaced with ‘q’.
Input: str = “geeks”
Input: str = “plmabc”
Approach: For every lowercase character of the English alphabet, insert the character next to it in the keyboard in an unordered_map. Now traverse the given string character by character, and update every character with the map created earlier.
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find a string such that every character is lexicographically greater than its immediate next character
- Find the player to last modify a string such that even number of consonants and no vowels are left in the string
- Map every character of one string to another such that all occurrences are mapped to the same character
- Modify string by increasing each character by its distance from the end of the word
- Modify given array by incrementing first occurrence of every element by K
- Modify the string such that it contains all vowels at least once
- gets() is risky to use!
- Schedule jobs so that each server gets equal load
- Minimum string such that every adjacent character of given string is still adjacent
- Find Index of 0 to be replaced with 1 to get longest continuous sequence of 1s in a binary array
- Find Index of 0 to be replaced with 1 to get longest continuous sequence of 1s in a binary array | Set-2
- Minimum characters to be replaced to remove the given substring
- Minimum number of elements to be replaced to make the given array a Fibonacci Sequence
- Minimum number of 1's to be replaced in a binary array
- Minimum characters to be replaced to make frequency of all characters same
- Find next Smaller of next Greater in an array
- Minimum operations required to modify the array such that parity of adjacent elements is different
- Modify array by merging elements with addition such that it consists of only Primes.
- Replace every vowels with lexicographically next vowel in a String
- Replace every character of string by character whose ASCII value is K times more than it
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.