cswork / OAOpen practice workspace

Goldman SachsOA #7

Decoding String

Estimated EasyStatement and editorial — judging is being prepared

Topics (AI-labelled)Strings

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.

Constraints

  • 1 ≤ |s| ≤ 10⁵
  • s[i]is an ascii character in the range [A-Z a-z] or a space character

Editorial

Loading solution…