Leetcode 43. Multiply Strings
来源:互联网 发布:免费音乐广告制作软件 编辑:程序博客网 时间:2024/05/21 19:23
public class Solution { public String multiply(String num1, String num2) { int m = num1.length(), n = num2.length(); int[] pos = new int[m + n]; for(int i = m - 1; i >= 0; i--) { for(int j = n - 1; j >= 0; j--) { int mul = (num1.charAt(i) - '0') * (num2.charAt(j) - '0'); int p1 = i + j, p2 = i + j + 1; int sum = mul + pos[p2]; pos[p1] += sum / 10; pos[p2] = (sum) % 10; } } StringBuilder sb = new StringBuilder(); for(int p : pos) sb.append(p); return sb.length() == 0 ? "0" : sb.toString(); }}
0 0
- [LeetCode]43.Multiply Strings
- LeetCode --- 43. Multiply Strings
- [Leetcode] 43. Multiply Strings
- [leetcode] 43.Multiply Strings
- 43. Multiply Strings LeetCode
- leetcode 43. Multiply Strings
- LeetCode 43. Multiply Strings
- LeetCode 43. Multiply Strings
- LeetCode 43. Multiply Strings
- [leetcode] 43. Multiply Strings
- Leetcode 43. Multiply Strings
- (Leetcode)43. Multiply Strings
- LeetCode - 43. Multiply Strings
- leetcode 43. Multiply Strings
- [LeetCode] 43. Multiply Strings
- leetcode 43. Multiply Strings
- Leetcode 43. Multiply Strings
- leetcode 43. Multiply Strings
- Leetcode 98. Validate Binary Search Tree
- Leetcode 100. Same Tree
- COVER王锐大大——最长的一帧(第四日)
- Leetcode 101. Symmetric Tree
- Python轻松入门-09 Range函数和While循环
- Leetcode 43. Multiply Strings
- Rails:Ubuntu下连接Git提示Permission denied的解决方法
- [python]mac安装virtualenv
- callee caller
- 开发板串口连接
- Maze CodeForces - 377A
- 第三十四课:数组操作符的重载----------狄泰软件学院
- unity学习笔记03-prefab
- HP DeskJet 2131 喷墨一体打印机打印设置教程