Skip to content

Practice Count Largest Group

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1399
LeetCode Problem

Count Largest Group

Problem Statement

You are given an integer n. We need to group the numbers from 1 to n according to the sum of its digits. For example, the numbers 14 and 5 belong to the same group, whereas 13 and 3 belong to different groups. Return the number of groups that have the largest size, i.e. the maximum number of elements.

Source: Count Largest Group on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 13
Output
4

# Example 2

Input
n = 2
Output
2

Constraints

1 <= n <= 10^4

Related LeetCode Problems

Practice more problems similar to Count Largest Group.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.