Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Matrix
- hash table
- Number Theory
- bit manipulation
- 자바
- two pointers
- 코테
- Data Structure
- string
- database
- Stack
- sorting
- Method
- geometry
- implement
- dynamic programming
- 코딩테스트
- SQL
- Class
- Binary Tree
- simulation
- 구현
- Tree
- Binary Search
- array
- Math
- 파이썬
- greedy
- Counting
- java
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 2180. Count Integers With Even Digit Sum 본문
1. Input
1) 정수 num
2. Output
1) num 이하의 자연수 중에서 각 자릿수의 합이 짝수인 자연수의 개수
3. Constraint
1) 1 <= num <= 1000
4. Example
Input: num = 30 -> Output: 14
설명: 30 이하의 자연수 중에서 각 자릿수의 합이 짝수인 것은 총 14개가 있다.
- 1자리 수: 2, 4, 6, 8
- 2자리 수: 11(1+1=2), 13(1+3=4), 15, 17, 19, 20, 22, 24, 26, 28
5. Code
1) 첫 코드(2022/06/22)
int count = 0;
for(int i=2 ; i<=num ; i++){
int s = 0;
int n = i;
while(n>=1){
s += n%10;
n /= 10;
}
if(s%2==0)
count++;
}
return count;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2194. Cells in a Range on an Excel Sheet (0) | 2023.01.15 |
---|---|
[LeetCode/Easy] 2185. Counting Words With a Given Prefix (0) | 2023.01.15 |
[LeetCode/Easy] 2176. Count Equal and Divisible Pairs in an Array (0) | 2023.01.15 |
[LeetCode/Medium] 1689. Partitioning Into Minimum Number Of Deci-Binary Numbers (0) | 2023.01.15 |
[LeetCode/Easy] 2169. Count Operations to Obtain Zero (0) | 2023.01.13 |