Leetcode_1678_设计Goal解析器_水题

12/12

水题模拟
class Solution {
    
    
    public String interpret(String command) {
    
    
        String ans="";
        for(int i=0;i<command.length();i++){
    
    
            if(command.charAt(i)=='G'){
    
    
                ans+='G';
            }else if(command.charAt(i)=='('){
    
    
                if(command.charAt(i+1)==')'){
    
    
                    i++;
                    ans+='o';
                }else{
    
    
                    i+=3;
                    ans+="al";
                }
            }
        }
        return ans;
    }
}

猜你喜欢

转载自blog.csdn.net/HDUCheater/article/details/111058894