Goal Parser Interpretation (Leetcode 1678)
Problem Link: https://leetcode.com/problems/goal-parser-interpretation/
class Solution:
def interpret(self, command: str) -> str:
ans=''
i=0
while(i<len(command)):
if(command[i]=='G'):
ans=ans+'G'
i+=1
elif(command[i]=='(' and command[i+1]==')'):
ans=ans+'o'
i+=2
else:
ans=ans+'al'
i+=4
return ans
PreviousJewels and Stones (Leetcode 771)NextMaximum Number of Words Found in Sentences (Leetcode 2114)
Last updated