-
Leetcode 1678. Goal Parser Interpretation개발/Leetcode 2023. 7. 2. 10:45
https://leetcode.com/problems/goal-parser-interpretation/description/
문제
당신은 주어지는 command를 해석하는 Goal Parser의 주인이다. command는 "G", "()" 그리고 "(al)"로 이루어져 있다. Goal Parer는 "G"는 "G" 그대로 해석하고, "()"는 "o"로 해석한다. 마지막으로 "(al)"은 "al"로 해석한다. 주어진 command를 위와같이 해석하여 반환하여라
코드
import re
class Solution:def interpret(self, command: str) -> str:# () parseanswer = ""answer = re.sub(r'\(\)', 'o', command)# (al) parseanswer = re.sub(r'\(al\)', 'al', answer)return answer'개발 > Leetcode' 카테고리의 다른 글
Leetcode 859. Buddy Strings (0) 2023.07.03 Leetcode 2114. Maximum Number of Words Found in Sentences (0) 2023.07.02 Leetcode 744. Find Smallest Letter Greater Than Target (0) 2023.07.02 Leetcode 2011. Final Value of Variable After Performing Operations (0) 2023.07.02 Leetcode 43. Multiply Strings (0) 2023.07.01