Skip to content

Commit b8cad10

Browse files
authored
Create percentage-of-letter-in-string.py
1 parent a5e97f3 commit b8cad10

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
# string
5+
class Solution(object):
6+
def percentageLetter(self, s, letter):
7+
"""
8+
:type s: str
9+
:type letter: str
10+
:rtype: int
11+
"""
12+
return 100*s.count(letter)//len(s)

0 commit comments

Comments
 (0)