-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterpret.java
More file actions
28 lines (27 loc) · 763 Bytes
/
interpret.java
File metadata and controls
28 lines (27 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Solution {
public String interpret(String command) {
StringBuilder sb=new StringBuilder();
int i=0;
while(i<command.length()){
switch(command.charAt(i)){
case 'G':{
sb.append("G");
i++;
break;
}
case '(':{
if(command.charAt(i+1)==')'){
sb.append("o");
i+=2;
break;
}else{
sb.append("al");
i+=4;
break;
}
}
}
}
return sb.toString();
}
}