Leetcode Problem 1309. Decrypt String from Alphabet to Integer Mapping
1309. Decrypt String from Alphabet to Integer Mapping
Leetcode Solutions
Iterative Decoding with Lookahead
Initialize an empty string result to store the decoded characters.
Start iterating over the string s using a variable i.
Inside the loop, check if the current position i is less than the length of s minus 2 and if the character at position i+2 is a '#'.
If the '#' is found, calculate the number formed by the two digits before the '#' and convert it to the corresponding character. Append this character to result and increment i by 3.
If there is no '#', convert the current digit to the corresponding character and append it to result. Increment i by 1.
Continue this process until the end of the string is reached.