2278. Percentage of Letter in String
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 74% Topics: String
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(1)
# string
class Solution(object):
def percentageLetter(self, s, letter):
"""
:type s: str
:type letter: str
:rtype: int
"""
return 100*s.count(letter)//len(s)
Solution from kamyu104/LeetCode-Solutions · MIT
Similar questions