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
- rds
- kubernetes
- serverless
- CAP
- sns
- SageMaker
- CHECK
- Lamda
- terraform
- cloudwatch
- IaC
- 병목
- lambda
- 분산시스템
- Validation
- PACELC
- amazonqcli
- aws
- fcm
Archives
- Today
- Total
잡다한 IT 지식
1281. Subtract the Product and Sum of Digits of an Integer 본문

숫자 각 자릿수에 곱과 합을 빼서 리턴해주는 문제.
10으로 나눈 나머지가 1의 자릿수의 값이 됨.
0이 될 때까지 계속 반복하면 모든 자릿수를 거쳐갈 수 있음.
[내가 짠 코드]
class Solution {
public int subtractProductAndSum(int n) {
int number = n;
int multilSum = 1;
int sum = 0;
while (number > 0) {
int temp = number % 10;
sum += temp;
multilSum *= temp;
number /= 10;
}
return multilSum- sum;
}
}'알고리즘 문제 풀이' 카테고리의 다른 글
| 1431. Kids With the Greatest Number of Candies (0) | 2021.06.10 |
|---|---|
| 1827. Minimum Operations to Make the Array Increasing (0) | 2021.06.08 |
| (아직안끝남)1351. Count Negative Numbers in a Sorted Matrix (0) | 2021.06.02 |
| 1528. Shuffle String (0) | 2021.05.25 |
| 1561. Maximum Number of Coins You Can Get (0) | 2021.05.13 |