Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- PYTHON
- 백준
- 프로그래머스
- Baekjoon
- 자연어처리
- 캐치카페
- 프로그래머스 파이썬
- 맥북
- programmers
- AI 경진대회
- 더현대서울 맛집
- hackerrank
- 편스토랑
- Real or Not? NLP with Disaster Tweets
- Docker
- ubuntu
- 편스토랑 우승상품
- 데이콘
- ChatGPT
- SW Expert Academy
- github
- Git
- dacon
- leetcode
- Kaggle
- 우분투
- gs25
- 금융문자분석경진대회
- 코로나19
- 파이썬
Archives
- Today
- Total
솜씨좋은장씨
[leetCode] 1678. Goal Parser Interpretation (Python) 본문
Programming/코딩 1일 1문제
[leetCode] 1678. Goal Parser Interpretation (Python)
솜씨좋은장씨 2020. 12. 8. 00:43728x90
반응형

You own a Goal Parser that can interpret a string command. The command consists of an alphabet of "G", "()" and/or "(al)" in some order. The Goal Parser will interpret "G" as the string "G", "()" as the string "o", and "(al)" as the string "al". The interpreted strings are then concatenated in the original order.
Given the string command, return the Goal Parser's interpretation of command.
Example 1:
Input: command = "G()(al)"
Output: "Goal"
Explanation: The Goal Parser interprets the command as follows:
G -> G
() -> o
(al) -> al
The final concatenated result is "Goal".
Example 2:
Input: command = "G()()()()(al)"
Output: "Gooooal"
Example 3:
Input: command = "(al)G(al)()()G"
Output: "alGalooG"
Constraints:
- 1 <= command.length <= 100
- command consists of "G", "()", and/or "(al)" in some order.
Solution
class Solution:
def interpret(self, command: str) -> str:
command = command.replace("()", "o").replace("(al)", "al")
return command



SOMJANG/CODINGTEST_PRACTICE
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[leetCode] 1662. Check If Two String Arrays are Equivalent (Python) (0) | 2020.12.12 |
---|---|
[leetCode] 1672. Richest Customer Wealth (Python) (0) | 2020.12.09 |
[leetCode] 1588. Sum of All Odd Length Subarrays (Python) (0) | 2020.12.07 |
[leetCode] 1436. Destination City (Python) (0) | 2020.12.06 |
[leetCode] 744. Find Smallest Letter Greater Than Target (Python) (0) | 2020.12.05 |