-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGoal Parser Interpretation.cpp
More file actions
40 lines (39 loc) · 947 Bytes
/
Goal Parser Interpretation.cpp
File metadata and controls
40 lines (39 loc) · 947 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
29
30
31
32
33
34
35
36
37
38
39
40
/*
Platform :- Leetcode
Question :- Global Parser Interpretation ( Weekly contest 218 )
Approach :- check for (),(al) & G - in the string and replace with desired characters
*/
class Solution {
public:
string interpret(string c) {
string ans;
int f=0;
for(int i=0;i<c.size();++i){
if(c[i]=='G'){
ans+=c[i];
}
else{
if(f){
if(c[i]==')')
{
ans+='o';
f=0;
}
else
{
ans+="al";
i+=2;
f=0;
}
}
else
{
if(c[i]=='('){
f=1;
}
}
}
}
return ans;
}
};