String 2278. Percentage of Letter in String ¶ Time: $O(n)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6class Solution { public: int percentageLetter(string s, char letter) { return 100 * ranges::count(s, letter) / s.length(); } }; 1 2 3 4 5class Solution { public int percentageLetter(String s, char letter) { return 100 * (int) s.chars().filter(c -> c == letter).count() / s.length(); } } 1 2 3class Solution: def percentageLetter(self, s: str, letter: str) -> int: return 100 * s.count(letter) // len(s)