Percentage of Letter in String
Return the percentage of characters in s that equal the single character letter, rounded down to the nearest whole percent (an int).
Example 1
s "foobar"
letter "o"
returns 33
2 of 6 characters, which is 33.3%, rounded down to 33.
Constraints
1 <= len(s) <= 100letteris one lowercase letter
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Strings problems
- Prefix of Any Word in a SentenceBeginner
- Remove Vowels from a StringBeginner
- Reverse Each WordBeginner
- Reverse Prefix of WordBeginner
- Reverse StringBeginner
- Snake Case to Camel CaseBeginner
- Stretch Each CharacterBeginner
- Student Attendance RecordBeginner