https://leetcode.com/problems/percentage-of-letter-in-string/description/
Percentage of Letter in String - LeetCode
Can you solve this real interview question? Percentage of Letter in String - Given a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent. Example 1: Input: s = "foobar", l
leetcode.com
1 2 3 | class Solution: def percentageLetter(self, s: str, letter: str) -> int: return int((s.count(letter) / len(s)) * 100) | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 1304. Find N Unique Integers Sum up to Zero (0) | 2024.01.10 |
---|---|
leetcode 1636. Sort Array by Increasing Frequency (0) | 2024.01.09 |
leetcode 2500. Delete Greatest Value in Each Row (0) | 2024.01.07 |
leetcode 2706. Buy Two Chocolates (0) | 2024.01.05 |
leetcode 2843. Count Symmetric Integers (0) | 2024.01.05 |
댓글