LeetCode 394 Decode String 递归方法

class Solution {
public:
    string find(string& patten,int i,int &n){ //i是一对[]开始的位置,n是返回值,一对[]结束位置
        string decoded="";
        string str="";
        stringstream s;
        int end; 

        while(1){

            if(i>=patten.size()) return decoded;

            if(patten[i]=='[') {i++;continue;}
            else if(patten[i]==']') {
                n=i+1;
                break;
            }
            else if(patten[i]>='0' && patten[i]<='9'){
                int count=0;
                while(patten[i]>='0' && patten[i]<='9')
                {
                    int d=patten[i]-'0';
                    count=count*10 + d;
                    i++;
                }
                str=find(patten,i+1,end);
                for(int j=0;j

你可能感兴趣的:(LeetCode 394 Decode String 递归方法)