首页 > 其他分享 >1678. 设计 Goal 解析器

1678. 设计 Goal 解析器

时间:2022-11-06 01:22:09浏览次数:103  
标签:解析器 ch Goal 1678 sb append

1678. 设计 Goal 解析器

class Solution {
    public String interpret(String command) {
        char[] ch = command.toCharArray();
        int n = ch.length;
        StringBuilder sb = new StringBuilder();
        for(int i = 0 ; i < n; i ++) {
            if (ch[i] == 'G') sb.append(ch[i]);
            if (ch[i] == '(') {
                i++;
                if (ch[i] == ')') {
                    sb.append('o');
                }
                else {
                    sb.append("al");
                    i+=2;
                }
            }
        }
        return sb.toString();
    }
}

标签:解析器,ch,Goal,1678,sb,append
From: https://www.cnblogs.com/eiffelzero/p/16861815.html

相关文章