Given an encrypted string str and the encryption algorithm, the task is to decrypt the string. The encryption algorithm is as follows:
The 1st character of the string will be repeated once in the encrypted string, the 2nd character will be repeated twice, …, nth character will be repeated n times. For example, string “abcd” will be encrypted as “abbcccdddd”.
Input: str = “geeeeekkkksssss”
Input: str = “abbcccdddd”
Approach: Initialize i = 0 and print str[i].
Update i = i + 1 and print str[i] then update i = i + 2 and print str[i] and so on while i < length(str).
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.
- Restore original String from given Encrypted String by the given operations
- Encrypt a string by repeating i-th character i times
- Program to find the Encrypted word
- Decrypt a string according to given rules
- Decrypt the String according to given algorithm
- Replace every character of string by character whose ASCII value is K times more than it
- Queries to find the last non-repeating character in the sub-string of a given string
- Queries to find the first non-repeating character in the sub-string of a string
- Given a string, find its first non-repeating character
- Maximum consecutive repeating character in string
- First non-repeating character using one traversal of string | Set 2
- Find the last non repeating character in string
- Find first non-repeating character in a given string using Linked List
- Maximum repeating character for every index in given String
- K'th Non-repeating Character
- Queue based approach for first non-repeating character in a stream
- Find the first non-repeating character from a stream of characters
- K’th Non-repeating Character in Python using List Comprehension and OrderedDict
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Check if max occurring character of one string appears same no. of times in other
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.