leetcode 1678. Goal Parser Interpretation
Problem: 1678. 设计 Goal 解析器
遍历,然后拼接起来就可以的
Code
class Solution { public: string interpret(string command) { int n = command.size(); string ret; for(int i = 0; i < n; i++) { if(command[i]=='G') { ret += 'G'; }else if(command[i]=='(' && command[i+1]==')') { ret += 'o'; i++; }else { ret += "al"; i += 3; } } return ret; } };