2022-05-24 20:20:53 +08:00
< p > Given a string < code > s< / code > and a character < code > letter< / code > , return< em > the < strong > percentage< / strong > of characters in < / em > < code > s< / code > < em > that equal < / em > < code > letter< / code > < em > < strong > rounded down< / strong > to the nearest whole percent.< / em > < / p >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-05-24 20:20:53 +08:00
< pre >
< strong > Input:< / strong > s = " foobar" , letter = " o"
< strong > Output:< / strong > 33
< strong > Explanation:< / strong >
The percentage of characters in s that equal the letter ' o' is 2 / 6 * 100% = 33% when rounded down, so we return 33.
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-05-24 20:20:53 +08:00
< pre >
< strong > Input:< / strong > s = " jjjj" , letter = " k"
< strong > Output:< / strong > 0
< strong > Explanation:< / strong >
The percentage of characters in s that equal the letter ' k' is 0%, so we return 0.< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = s.length < = 100< / code > < / li >
< li > < code > s< / code > consists of lowercase English letters.< / li >
< li > < code > letter< / code > is a lowercase English letter.< / li >
< / ul >