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 | 29 | 30 | 31 |
Tags
- Binary Search
- Class
- Math
- 코딩테스트
- database
- greedy
- Tree
- Counting
- 구현
- Binary Tree
- 코테
- dynamic programming
- Stack
- SQL
- hash table
- implement
- Number Theory
- geometry
- string
- Matrix
- array
- 자바
- two pointers
- simulation
- sorting
- bit manipulation
- 파이썬
- Method
- java
- Data Structure
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 2520. Count the Digits That Divide a Number 본문
1. Input
1) int num
2. Output
1) num을 이루고 있는 숫자 중 num의 약수의 개수를 반환
- 중복되는 숫자도 세야 한다.
3. Constraint
1) 1 <= num <= 10^9
2) num에는 0이 없다.
4. Example
Input: num = 121 -> Output: 2
설명: num에는 1, 2, 1 3개의 숫자가 있고, 이 중 121의 약수는 1, 1 2개이므로 2를 반환한다.
5. Code
1) 첫 코드(2023/05/06)
class Solution {
public int countDigits(int num) {
int n = num, answer = 0;
while(n>0){
int x = n%10;
n /= 10;
if(num%x==0)
answer++;
}
return answer;
}
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2549. Count Distinct Numbers on Board (0) | 2023.05.06 |
---|---|
[LeetCode/Easy] 2540. Minimum Common Value (0) | 2023.05.06 |
[LeetCode/Easy] 2515. Shortest Distance to Target String in a Circular Array (0) | 2023.05.06 |
[LeetCode/Easy] 2511. Maximum Enemy Forts That Can Be Captured (0) | 2023.05.06 |
[LeetCode/Easy] 2506. Count Pairs Of Similar Strings (0) | 2023.05.06 |