/**
* @param {string} num1
* @param {string} num2
* @return {string}
*/
var multiply = function(num1, num2) {
num1 = num1.split("").reverse().join("");
num2 = num2.split("").reverse().join("");
var arr = new Array();
var push = 0;
for(var loop2 = 0;loop2 < num2.length;loop2++){
for(var loop1 = 0;loop1 < num1.length;loop1++){
var temp = num2[loop2] * num1[loop1];
var curValue = arr[loop1 + loop2] ? arr[loop1 + loop2] : 0;
curValue = Number(curValue) + Number(push) + Number(temp);
push = parseInt(curValue / 10);
arr[loop2 + loop1] = curValue % 10;
}
if(push){
arr[loop2 + loop1] = push;
push = 0;
}
}
arr = arr.reverse(); var rst = "";
for(var loop = 0;loop < arr.length;loop++){
if(!arr[loop] == 0 || !rst==''){
rst += arr[loop];
}
}
if(rst=='')return "0";
return rst;
};

  

43. Multiply Strings的更多相关文章

  1. [Leetcode][Python]43: Multiply Strings

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 43: Multiply Stringshttps://leetcode.co ...

  2. [LeetCode] 415 Add Strings && 67 Add Binary && 43 Multiply Strings

    这些题目是高精度加法和高精度乘法相关的,复习了一下就做了,没想到难住自己的是C++里面string的用法. 原题地址: 415 Add Strings:https://leetcode.com/pro ...

  3. [LeetCode] 43. Multiply Strings ☆☆☆(字符串相乘)

    转载:43. Multiply Strings 题目描述 就是两个数相乘,输出结果,只不过数字很大很大,都是用 String 存储的.也就是传说中的大数相乘. 解法一 我们就模仿我们在纸上做乘法的过程 ...

  4. 【LeetCode】43. Multiply Strings

    Multiply Strings Given two numbers represented as strings, return multiplication of the numbers as a ...

  5. [LeetCode] 43. Multiply Strings 字符串相乘

    Given two non-negative integers num1 and num2represented as strings, return the product of num1 and  ...

  6. LeetCode(43. Multiply Strings)

    题目: Given two numbers represented as strings, return multiplication of the numbers as a string. Note ...

  7. Java [Leetcode 43]Multiply Strings

    题目描述: Given two numbers represented as strings, return multiplication of the numbers as a string. No ...

  8. 【LeetCode题意分析&解答】43. Multiply Strings

    Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...

  9. 【一天一道LeetCode】#43. Multiply Strings

    一天一道LeetCode系列 (一)题目 Given two numbers represented as strings, return multiplication of the numbers ...

  10. [leetcode]43. Multiply Strings高精度乘法

    Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and ...

随机推荐

  1. Android Time类 奇葩的设定

    Android 的Time.MONTH默认是0-11表示1-12月,小白表示坑爹啊,浪费多少精力啊.

  2. GJM : AlloyTouch实战--60行代码搞定QQ看点资料卡

    原文链接:https://github.com/AlloyTeam/AlloyTouch/wiki/kandian 先验货 访问DEMO你也可以点击这里 源代码可以点击这里 如你体验所见,流程的滚动的 ...

  3. datagrid与webAPI的数据交互(ef mvc )

    datagride自带分页工具,当使用分页工具的时候,初始化datagride或者带数据提交到API里面时,会以Json对象的形式将数据传递到API控制器里面,当没有过滤条件或者请求参数.和提交参数的 ...

  4. LoadRunner免费公开课,惠普金牌讲师亲授

    [开课时间]:9月13日 下午2:00—4:00(暂定)[活动费用]:免费[主办单位]:慧都学院[课程形式]:网络在线公开课 LoadRunner简介惠普软件测试解决方案LoadRunner测试实例答 ...

  5. 在xampp中配置dvwa

    DVWA主要是用于学习Web的常见攻击,比如SQL注入.XSS等的一个渗透测试系统,下面我将结合XAMPP来说明它的安装过程. 一.环境 OS:Windows 10 XAMPP:5.6.24 DVWA ...

  6. Javascript前端和JAVA后端对加密库的处理实例

    前端加密 Javascript的加解密有开源的库,http://www.oschina.net/p/crypto-js/ 如下是具体的使用例子 <!DOCTYPE html> <ht ...

  7. NSDateFormatter 时间格式转换

    NSString *strDate = @“Wed Apr ::”; NSDateFormatter *dateFomatter =[[NSDateFormatter alloc] init]; [d ...

  8. 安卓开发之ListAdapter(二)

    今天我们来学习一下ArrayAdapter: ArrayAdapter是安卓中最简单的适配器.使用ArrayAdapter(数组适配器),需要把数据源存 放至数组里面来显示. •构造函数: publi ...

  9. Highcharts入门小示例

    一.创建条形图 1.创建div容器 <div id="container" style="min-width:800px;height:400px"> ...

  10. (二)Spark-Linux环境准备-Java&Python版Spark

    Spark-Linux环境准备 视频教程: 1.优酷 2.YouTube 硬软件环境 1.虚拟机:VMware Workstation 12 2.虚拟机操作系统:RedHat5u4,单核,1G内存,2 ...