Replace All Digits with Characters

PHOTO EMBED

Sat Oct 08 2022 17:00:45 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

class Solution {
public:
    string replaceDigits(string s) {
        int n=s.size();
        string p="";
        for(int i=0;i<n;i++)
        {
            if((s[i]-'0')>=0 && (s[i]-'0')<=9)
            {
                p+=(s[i-1]+(s[i]-'0'));
                
            }
            else 
            {
                p+=s[i];
            }
        }
        return p;
    }
};
content_copyCOPY

https://leetcode.com/problems/replace-all-digits-with-characters/