https://leetcode.com/problems/count-asterisks/description/
Count Asterisks - LeetCode
Count Asterisks - You are given a string s, where every two consecutive vertical bars '|' are grouped into a pair. In other words, the 1st and 2nd '|' make a pair, the 3rd and 4th '|' make a pair, and so forth. Return the number of '*' in s, excluding the
leetcode.com
1
2
3
4
5
6
7
|
class Solution:
def countAsterisks(self, s: str) -> int:
converted_s = s.split('|')
converted_s = ''.join(converted_s[::2])
answer = converted_s.count('*')
return answer
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2485. Find the Pivot Integer (0) | 2023.01.10 |
---|---|
leetcode 2418. Sort the People (0) | 2023.01.09 |
leetcode 2367. Number of Arithmetic Triplets (0) | 2023.01.08 |
백준 10203 Count Vowels (0) | 2023.01.07 |
leetcode 2520. Count the Digits That Divide a Number (0) | 2023.01.06 |
댓글