[LeetCode]#1309. Decrypt String from Alphabet to Integer Mapping

Environment: Python 3.7

Key technique: chr

Given a string s formed by digits ('0' - '9') and '#' . We want to map s to English lowercase characters as follows:

  • Characters ('a' to 'i') are represented by ('1' to '9') respectively.
  • Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.

Return the string formed after mapping.

It’s guaranteed that a unique mapping will always exist.

Example 1:

Analysis:

  1. In while loop if i < s length and i+2=”#”, this is double digit.
  2. Else is single digit.
  3. use char to covert to letter as below.

Solution:

Submission:

Reference:

https://coordinate.wang/index.php/archives/2843/

--

--

Interesting in any computer science.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store