aboutsummaryrefslogtreecommitdiff
path: root/multiply_strings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'multiply_strings.cpp')
-rw-r--r--multiply_strings.cpp26
1 files changed, 0 insertions, 26 deletions
diff --git a/multiply_strings.cpp b/multiply_strings.cpp
deleted file mode 100644
index 115b85c..0000000
--- a/multiply_strings.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "leetcode.h"
-
-class Solution {
-public:
- string multiply(string num1, string num2) {
- if (num1 == "0" || num2 == "0")
- return "0";
- vector<int> res(num1.size() + num2.size(), 0);
- for (int i = num1.size() - 1; i >= 0; i--) {
- for (int j = num2.size() - 1; j >= 0; j--) {
- res[i + j + 1] += (num1[i] - '0') * (num2[j] - '0');
- res[i + j] += res[i + j + 1] / 10;
- res[i + j + 1] %= 10;
- }
- }
- int i = 0;
- string ans = "";
- while (res[i] == 0)
- i++;
- while (i < res.size())
- ans += to_string(res[i++]);
- return ans;
- }
-};
-
-int main() {}