[Leetcode] 5279. Subtract the Product and Sum of Digits of an Integer

class Solution {
public int subtractProductAndSum(int n) {
int productResult = 1;
int sumResult = 0;
do {
int currentval = n % 10;
productResult *= currentval;
sumResult += currentval;
n /= 10;
}while(n > 0);
return productResult - sumResult;
}
}
[Leetcode] 5279. Subtract the Product and Sum of Digits of an Integer的更多相关文章
- 【leetcode】1281. Subtract the Product and Sum of Digits of an Integer
题目如下: Given an integer number n, return the difference between the product of its digits and the sum ...
- leetcode面试准备:Minimum Size Subarray Sum
leetcode面试准备:Minimum Size Subarray Sum 1 题目 Given an array of n positive integers and a positive int ...
- [Leetcode 40]组合数和II Combination Sum II
[题目] Given a collection of candidate numbers (candidates) and a target number (target), find all uni ...
- [Leetcode 39]组合数的和Combination Sum
[题目] Given a set of candidate numbers (candidates) (without duplicates) and a target number (target) ...
- Product and Sum in Category Theory
Even if you are not a functional programmer, the notion of product type should be familiar to you, e ...
- CodeForces 489C Given Length and Sum of Digits... (贪心)
Given Length and Sum of Digits... 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/F Descr ...
- Sum of Digits / Digital Root
Sum of Digits / Digital Root In this kata, you must create a digital root function. A digital root i ...
- Maximum Sum of Digits(CodeForces 1060B)
Description You are given a positive integer nn. Let S(x) be sum of digits in base 10 representation ...
- Codeforces Round #277.5 (Div. 2)C——Given Length and Sum of Digits...
C. Given Length and Sum of Digits... time limit per test 1 second memory limit per test 256 megabyte ...
随机推荐
- 【Spring Boot】Spring Boot之使用ImportBeanDefinitionRegistrar类实现动态注册Bean
一.ImportBeanDefinitionRegistrar类介绍 ImportBeanDefinitionRegistrar类通过其他@Configuration类通过@Import的方式来加载, ...
- CentOS7安装Oracle11gR2
转自E路情人https://www.cnblogs.com/Q1013588888/p/9219128.html 一.安装CentOS-7_x86_64 1.CentOS7:带GUI的服务器(FTP ...
- Linux-CentOS-Nginx安装
原文转自 jerryhe326:https://www.cnblogs.com/jerrypro/p/7062101.html 一.安装准备 首先由于nginx的一些模块依赖一些lib库,所以在安装n ...
- JS高阶---闭包面试题
[面试题1] 答案:The Window 分析: 本案例里,不存在闭包. 条件: .函数嵌套(满足) .内部函数调用外部函数变量(没有) 综上所述,该例中不存在闭包 [面试题2] 答案:My Obje ...
- linux翻页及字符串搜索操作
向下翻动一屏幕: space, ctrl + f, ctrl + v, ctrl + F 向下翻动半屏: d, ctrl + D 向下翻动一行: 回车, e, j 向上翻动一屏幕: b, ctrl + ...
- [LeetCode] 902. Numbers At Most N Given Digit Set 最大为 N 的数字组合
We have a sorted set of digits D, a non-empty subset of {'1','2','3','4','5','6','7','8','9'}. (Not ...
- [LeetCode] 598. Range Addition II 范围相加之二
Given an m * n matrix M initialized with all 0's and several update operations. Operations are repre ...
- [LeetCode] 27. Remove Element 移除元素
Given an array nums and a value val, remove all instances of that value in-place and return the new ...
- 多模态数据联合Embedding的方法小结
当模型需要接受多个模态的数据时,往往需要设计合适的方法让他们能进行信息的融合,Joint embedding是一种较为普遍的思路,即将他们映射到同一个向量空间中,再进行融合. 向量拼接.元素级相乘.做 ...
- qt no doubments matching "ui..h" could be found
问题情境描述: 自己单独添加的UI文件,然后添加一个类来使用这个UI文件,第一次输入UI Form名称时是大写,被添加到工程里面就是大写, 大写的情况下,添加action转到槽就会提示这个错误. 修改 ...