Description
Solutions
Submission
Decoding String
🤘 INTERN

Many simple encoding methods have been devised over the years. A common method is the ASCII character set used to display characters on the screen. Each character is given a numeric value which can be interpreted by the computer.

To decode the string, first reverse the string of digits, then successively pick valid values from the string and convert them to their ASCII equivalents. Some of the values will have two digits, and others three. Use the ranges of valid values when decoding the string of digits.

  • The value range for A through Z is 65 through 90.
  • The value range from a through z is 97 through 122.
  • The value of the space character is 32.
  • Given a string, decode it following the steps mentioned above.

    Function Description

    Complete the function decode.

    decode has the following parameter(s):

  • string encode: an encoded string
  • Return

    string: the original decoded string decode.

    Example 1:

    Input:  encode = "HackerRank"
    Output: "729799107101114328297110107"
    Explanation:
    The table above shows the conversion from the string HackerRank to the ASCII string 729799107101114328297110107. The last step of encoding is to reverse the ASCII string: 7010117928411101701997927.
    Constraints:
    • 1 <= |s| <= 105
    • s[i]is an ascii character in the range [A-Z a-z] or a space character
    Testcase

    Result
    Case 1

    input:

    output: