• Skip to primary navigation
  • Skip to content
  • Skip to footer
zhicheng xie's demo blog
  • Quick-Start Guide

    Your Name

    I am an amazing person.

    • Somewhere

    Decrypt String from Alphabet to Integer Mapping

    less than 1 minute read

    <-E> Decrypt String from Alphabet to Integer Mapping

    class Solution {
    public:
        string freqAlphabets(string s) {
            string a = "";
            int b;
            for(int i = s.size() - 1; i >= 0; i--) {
                if(s[i] != '#')
                    b = s[i] - '0' + 96;
                else {
                    b =   (s[i - 2] - '0' )* 10 +  (s[i - 1] - '0' ) + 96;
                    i -= 2;
                }
                a = (char)b + a;
            }
            return a;
        }
    };
    

    Tags: Algorithms, C++, Leetcode

    Updated: January 15, 2020

    Share on

    Twitter Facebook LinkedIn
    Previous Next

    You may also enjoy

    Decode Ways

    less than 1 minute read

    <-M 91> Decode Ways

    Word Break

    less than 1 minute read

    <-H 139> Word Break

    Distinct Subsequences

    less than 1 minute read

    <-H 115> Distinct Subsequences

    Edit Distance

    less than 1 minute read

    <-H 72> Edit Distance

    • Follow:
    • Feed
    © 2023 zhicheng xie's blog. Powered by Jekyll & Minimal Mistakes.