[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 ...
随机推荐
- 网络唤醒(WOL)全解指南:原理篇【转】
转自:https://blog.csdn.net/z5859095/article/details/82819075 什么是网络唤醒网络唤醒(Wake-on-LAN,WOL)是一种计算机局域网唤醒技术 ...
- pytest怎么标记用例?
pytest还有一个很强大的功能,那就是标记用例这个功能,这个功能可真的是很实用哒 首先,我们要实现标记功能,得分为3步走: 1.注册标记 2.标记用例 3.运行已经标记的用例. 那么第一步我们怎么实 ...
- reduce计算数组中每个元素出现的次数 数组去重的几种方式 将多维数组转化为一维
// js计算数组中每个元素出现的次数 // var names = ['Alice', 'Bob', 'Tiff', 'Bruce', 'Alice']; // var countedNames = ...
- linux open 黄色文件
表示设备文件 生成的新的pdf
- 201871010112-梁丽珍《面向对象程序设计(java)》第十四周学习总结
项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...
- day16_7.18 常用模块
一.collections collections模块中提供了除了dict,list,str等数据类型之外的其他数据类型:Counter.deque.defaultdict.namedtuple和Or ...
- COSO企业风险管理框架及其在大宗商品行业的应用
https://mp.weixin.qq.com/s/P1NDvqsz0GNObm1pb47mfg 中国期货市场交易量领先全球,期权.互换等新的衍生品工具逐步引入,场外衍生品服务商正在涌现.越来越多的 ...
- 万字长文把 VSCode 打造成 C++ 开发利器
https://zhuanlan.zhihu.com/p/96819625 面对大量代码,在开发任务繁重场景下,VSCode 绝对是一把利器.本文虽以 C++为引,但在 python.php.java ...
- n8n 试用
前边有简单的介绍n8n,如果大家看了官方网站会有一个比较醒目的说明zapier以及tray.io的开源替代方案 以下是一个简单的试用 环境准备 docker-compose 文件 version: ...
- ABP 不包裹返回的数据
告诉abp不包裹返回的数据,返回的数据是什么 就是什么 不用再多包裹一次了. 用在 如:别人需要你提供接口 且给你指定了返回的数据结构. 源码: