Skip to content

Commit a7cac83

Browse files
authored
Create 3945. Digit Frequency Score.java
1 parent fb7903c commit a7cac83

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// 0 ~ 9
2+
// O(log n)
3+
4+
class Solution {
5+
public int digitFrequencyScore(int n) {
6+
int result = 0;
7+
while (n>0) {
8+
int digit = n % 10;
9+
result += digit;
10+
n /= 10;
11+
}
12+
return result;
13+
}
14+
}

0 commit comments

Comments
 (0)