Leetcode Problem 1844. Replace All Digits with Characters

1844. Replace All Digits with Characters

Leetcode Solutions

Iterative Character Shifting

  1. Iterate over the string starting from index 1 to the end of the string, incrementing by 2 each time (to only look at odd indices).
  2. For each odd index i, convert the character at index i-1 to its ASCII code.
  3. Convert the character at index i (which is a digit) to an integer.
  4. Add the integer to the ASCII code.
  5. Convert the sum back to a character and replace the digit at index i with this new character.
  6. Continue this process until all odd indices have been processed.
  7. Return the modified string.
UML Thumbnail

Using a Lookup Alphabet String

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...