mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
29 lines
1.1 KiB
HTML
29 lines
1.1 KiB
HTML
<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>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<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>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<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>
|