Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc118389

Browse files
author
Steve Sun
committed
add 2180
1 parent3576b52 commitc118389

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|------|----------------|---------------|--------|-------------|-------------
11+
| 2180|[Count Integers With Even Digit Sum](https://leetcode.com/problems/count-integers-with-even-digit-sum/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2180.java)||Easy||
1112
| 2177|[Find Three Consecutive Integers That Sum to a Given Number](https://leetcode.com/problems/find-three-consecutive-integers-that-sum-to-a-given-number/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2177.java)||Medium||
1213
| 2176|[Count Equal and Divisible Pairs in an Array](https://leetcode.com/problems/count-equal-and-divisible-pairs-in-an-array/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2176.java)||Easy||
1314
| 2169|[Count Operations to Obtain Zero](https://leetcode.com/problems/count-operations-to-obtain-zero/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2169.java)||Easy||
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.ArrayList;
4+
importjava.util.List;
5+
6+
publicclass_2180 {
7+
publicstaticclassSolution1 {
8+
publicintcountEven(intnum) {
9+
intans =0;
10+
for (inti =1;i <=num;i++) {
11+
List<Integer>list =getAllDigits(i);
12+
intsum =0;
13+
for (intl :list) {
14+
sum +=l;
15+
}
16+
if (sum %2 ==0) {
17+
ans++;
18+
}
19+
}
20+
returnans;
21+
}
22+
23+
privateList<Integer>getAllDigits(intnum) {
24+
List<Integer>ans =newArrayList<>();
25+
while (num !=0) {
26+
ans.add(num %10);
27+
num /=10;
28+
}
29+
returnans;
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp