Given a string str, the task is to encrypt and reverse the string. The string is encrypted by adding every character of the string with it’s index in the string i.e. if character‘a’ is at index 2 then the character in the updated string will be ‘a’ + 2 = ‘c’. Since value of string may go beyond 256, do the addition under modulo 256.
Input: str = “geeks”
‘g’ + 0 = ‘g’
‘e’ + 1 = ‘f’
‘e’ + 2 = ‘g’
‘k’ + 3 = ‘n’
‘s’ + 4 = ‘w’
Input: str = “java”
- Add every character of the string with its index within the same string.
- Reverse the string.
- Print the reversed string.
Below is the implementation of the above approach:
- Reverse a string without affecting special characters
- Reverse alternate k characters in a string
- Reverse and Add Function
- Swap corner words and reverse middle characters
- Reverse Middle X Characters
- Check if a given string is a Reverse Bitonic String or not
- Replace minimal number of characters to make all characters pair wise distinct
- Reverse every word of the string except the first and the last character
- Check whether second string can be formed from characters of first string
- Remove characters from a numeric string such that string becomes divisible by 8
- Form N-copy string with add, remove and append operations
- Different methods to reverse a string in C/C++
- Print words of a string in reverse order
- PHP | Reverse a String
- Print reverse string after removing vowels
- Reverse String according to the number of words
- Reverse middle words of a string
- First string from the given array whose reverse is also present in the same array
- TCS Coding Practice Question | Reverse a String
- Reverse the given string in the range [L, R]
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.