image_2021-11-07_03-38-55.png
42.6 KB
#N1678. Goal Parser Interpretation
problem link
#solution
problem link
#solution
class Solution {
public String interpret(String command) {
String res="";
for(int i=0; i<command.length()-1; i++){
if(command.charAt(i)=='('&&command.charAt(i+1)==')')
res+="o";
else if(command.charAt(i)=='('&&command.charAt(i+1)=='a')
res+="al";
else if(command.charAt(i)=='G')
res+="G";
}
if(command.charAt(command.length()-1)=='G') res+="G";
return res;
}
}