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 | 31 |
Tags
- Real or Not? NLP with Disaster Tweets
- 더현대서울 맛집
- 우분투
- Kaggle
- ChatGPT
- 편스토랑 우승상품
- github
- Docker
- leetcode
- SW Expert Academy
- 데이콘
- 자연어처리
- 프로그래머스
- gs25
- Git
- 코로나19
- hackerrank
- 프로그래머스 파이썬
- 캐치카페
- programmers
- ubuntu
- PYTHON
- 파이썬
- 금융문자분석경진대회
- 편스토랑
- 백준
- 맥북
- dacon
- AI 경진대회
- Baekjoon
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
'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 |
Comments