Consider all codes made of four digits (0-9). How many of them have a sum of digits equal to S? For example, for S = 4, there are 35 such codes in total. Some of them are 0022, 1003, 1111, 2020, 4000.
that, given an integer S, returns the number of four-digit codes whose sum of digits is equal to S.
Assume that:
Sis an integer within the range[0..36].
In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.
Examples
01 Β· Example 1
S = 35 return = 4
The possible codes for
S = 35 are: 9998, 9989, 9899, 8999. Therefore, the function should return 4.02 Β· Example 2
S = 4 return = 35
ππ
03 Β· Example 3
S = 2 return = 10
π
Constraints
S is an integer within the range [0..36].More Google problems
- Periodic Table Word FormationsPHONE SCREEN Β· Seen Jun 2026
- Fountain SafetyONSITE INTERVIEW Β· Seen Jun 2026
- Consolidate On-Call RotationsOA Β· Seen Jun 2026
- Detonate Bombs with Chain ReactionsONSITE INTERVIEW Β· Seen May 2026
- Evaluate a Nested Math ExpressionONSITE INTERVIEW Β· Seen May 2026
- Tic-Tac-Toe Game StatusPHONE SCREEN Β· Seen May 2026
- Longest Dictionary TokenizationPHONE SCREEN Β· Seen May 2026
- Minimum Cars for Rental RequestsONSITE INTERVIEW Β· Seen Apr 2026
public int googleCountCodeWithSum(int S) {
// write your code here
}
S35
expected4
sign in to submit