Class Solution

java.lang.Object
g1301_1400.s1399_count_largest_group.Solution

public class Solution extends Object
1399 - Count Largest Group.<p>Easy</p> <p>You are given an integer <code>n</code>.</p> <p>Each number from <code>1</code> to <code>n</code> is grouped according to the sum of its digits.</p> <p>Return <em>the number of groups that have the largest size</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = 13</p> <p><strong>Output:</strong> 4</p> <p><strong>Explanation:</strong> There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13:</p> <p>[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9].</p> <p>There are 4 groups with largest size.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 2</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> There are 2 groups [1], [2] of size 1.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= n <= 10<sup>4</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • countLargestGroup

      public int countLargestGroup(int n)