# Score an Integer by Digit Frequencies
You are given a positive integer `n` written in decimal.
For each distinct digit `d` that appears in `n`, let `freq(d)` be its number of occurrences. Define the score as the sum of `d * freq(d)` over those distinct digits.
Return the score of `n`.
### Function
`int digitFrequencyScore(int n)`
### Example 1
**Input:** `n = 700707`
**Output:** `21`
**Explanation:** Digit `7` appears three times, contributing `7 * 3 = 21`. Digit `0` also appears three times and contributes `0`. Their total is `21`.
### Example 2
**Input:** `n = 1000000000`
**Output:** `1`
**Explanation:** Digit `1` appears once and digit `0` appears nine times. The score is `1 * 1 + 0 * 9 = 1`.
### Constraints
- `1 <= n <= 1000000000`
### Clarifications
- Frequencies are taken from the ordinary base-10 representation of the supplied integer.
- A repeated digit contributes its value once for every occurrence, through its frequency.
- A zero digit contributes `0`, regardless of how many times it appears.
### What a Strong Answer Covers
- Applying the frequency weight to every distinct digit correctly.
- Handling repeated digits, internal zeros and the ten-digit upper endpoint.
- Returning the score without changing the supplied integer outside the function.
Overview: Compute a positive integer’s digit-frequency score from the decimal digits, including repeated digits and zeros, for values up to one billion.
You are given a positive integer n written in decimal.
For each distinct digit d that appears in n, let freq(d) be its number of occurrences. Define the score as the sum of d * freq(d) over those distinct digits.
Return the score of n.
Function
int digitFrequencyScore(int n)
Example 1
Input:n = 700707
Output:21
Explanation: Digit 7 appears three times, contributing 7 * 3 = 21. Digit 0 also appears three times and contributes 0. Their total is 21.
Example 2
Input:n = 1000000000
Output:1
Explanation: Digit 1 appears once and digit 0 appears nine times. The score is 1 * 1 + 0 * 9 = 1.
Constraints
1 <= n <= 1000000000
Clarifications
Frequencies are taken from the ordinary base-10 representation of the supplied integer.
A repeated digit contributes its value once for every occurrence, through its frequency.
A zero digit contributes
0
, regardless of how many times it appears.
What a Strong Answer Covers Guidance
Applying the frequency weight to every distinct digit correctly.
Handling repeated digits, internal zeros and the ten-digit upper endpoint.
Returning the score without changing the supplied integer outside the function.