1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/统计最大组的数目 [count-largest-group].html
2022-03-29 12:43:11 +08:00

41 lines
1.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个整数 <code>n</code>&nbsp;。请你先求出从 <code>1</code>&nbsp;<code>n</code> 的每个整数 10 进制表示下的数位和(每一位上的数字相加),然后把数位和相等的数字放到同一个组中。</p>
<p>请你统计每个组中的数字数目,并返回数字数目并列最多的组有多少个。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>n = 13
<strong>输出:</strong>4
<strong>解释:</strong>总共有 9 个组,将 1 到 13 按数位求和后这些组分别是:
[1,10][2,11][3,12][4,13][5][6][7][8][9]。总共有 4 个组拥有的数字并列最多。
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>n = 2
<strong>输出:</strong>2
<strong>解释:</strong>总共有 2 个大小为 1 的组 [1][2]。
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>n = 15
<strong>输出:</strong>6
</pre>
<p><strong>示例 4</strong></p>
<pre><strong>输入:</strong>n = 24
<strong>输出:</strong>5
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10^4</code></li>
</ul>