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的更多相关文章

  1. 【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 ...

  2. leetcode面试准备:Minimum Size Subarray Sum

    leetcode面试准备:Minimum Size Subarray Sum 1 题目 Given an array of n positive integers and a positive int ...

  3. [Leetcode 40]组合数和II Combination Sum II

    [题目] Given a collection of candidate numbers (candidates) and a target number (target), find all uni ...

  4. [Leetcode 39]组合数的和Combination Sum

    [题目] Given a set of candidate numbers (candidates) (without duplicates) and a target number (target) ...

  5. 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 ...

  6. 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 ...

  7. Sum of Digits / Digital Root

    Sum of Digits / Digital Root In this kata, you must create a digital root function. A digital root i ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Rust中的哈希Map

    严谨! fn main() { use std::collections::HashMap; let mut scores = HashMap::new(); scores.insert(String ...

  2. node知识

    node中的url url中的方法: parse,resolve,format: 方法parse: 例子:url.parse('http://imooc.com/course/list'); 结果:{ ...

  3. Python获取帮助的3种方式(转载)

    我们可以很容易的通过Python解释器获取帮助.如果想知道一个对象(object)更多的信息,那么可以调用help(object)!另外还有一些有用的方法,dir(object)会显示该对象的大部分相 ...

  4. JUnit 4 和 TestNG

    JUnit 4和TestNG都是Java中非常受欢迎的单元测试框架.两种框架在功能上看起来非常相似.哪一个更好?在Java项目中应该使用哪个单元测试框架? 下面表中概括了JUnit 4和TestNG之 ...

  5. MyBatisPlus快速入门

    MyBatisPlus快速入门 官方网站 https://mp.baomidou.com/guide 慕课网视频 https://www.imooc.com/learn/1130 入门 https:/ ...

  6. pycharm访问mysql数据库

    不需要像eclipse那样添加驱动包,在pycharm里面下载一个pymysql包即可. 然后链接自己电脑的mysql并进行访问即可. 源码如下(参考博客:https://blog.csdn.net/ ...

  7. Wireshark的简单使用

    TCP包 先看一下Wireshark抓到的TCP的包对应的协议层: Frame:对应是物理层,主要是传输bit流. Ethernet:数据链路层,传输数据帧,二层通信主要是通过mac地址. Inter ...

  8. 学习:反调试之ZwQueryInformationProcess

    SetUnhandledExceptionFilter触发条件:1.当程序有异常,且没相应的处理 2.没有人进行反调试,满足这两个条件的时候,就会其中传输的参数(实则就是一个异常处理函数) 来进行处理 ...

  9. 11/3 <binary search>

    278. First Bad Version 二分法,如果isBadVersion返回true则坏版本在左边,right = mid,否则 left = mid + 1. 注意溢出问题 left+(r ...

  10. MySQL实战45讲学习笔记:第二十三讲

    一.本节概要 今天这篇文章,我会继续和你介绍在业务高峰期临时提升性能的方法.从文章标题“MySQL 是怎么保证数据不丢的?”,你就可以看出来,今天我和你介绍的方法,跟数据的可靠性有关. 在专栏前面文章 ...