mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			984 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			984 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个字符串 <code>s</code> 和一个字符 <code>letter</code> ,返回在 <code>s</code> 中等于 <code>letter</code> 字符所占的 <strong>百分比</strong> ,向下取整到最接近的百分比。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>s = "foobar", letter = "o"
 | 
						||
<strong>输出:</strong>33
 | 
						||
<strong>解释:</strong>
 | 
						||
等于字母 'o' 的字符在 s 中占到的百分比是 2 / 6 * 100% = 33% ,向下取整,所以返回 33 。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre>
 | 
						||
<strong>输入:</strong>s = "jjjj", letter = "k"
 | 
						||
<strong>输出:</strong>0
 | 
						||
<strong>解释:</strong>
 | 
						||
等于字母 'k' 的字符在 s 中占到的百分比是 0% ,所以返回 0 。</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= s.length <= 100</code></li>
 | 
						||
	<li><code>s</code> 由小写英文字母组成</li>
 | 
						||
	<li><code>letter</code> 是一个小写英文字母</li>
 | 
						||
</ul>
 |