File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
main/java/com/examplehub/leetcode/middle
test/java/com/examplehub/leetcode/middle Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .examplehub .leetcode .middle ;
2+
3+ import java .math .BigInteger ;
4+
5+ /**
6+ * https://leetcode.com/problems/multiply-strings/
7+ */
8+ public class MultiplyStrings {
9+ public static String solution1 (String num1 , String num2 ) {
10+ return String .valueOf (Integer .parseInt (num1 ) * Integer .parseInt (num2 ));
11+ }
12+
13+ public static String solution2 (String num1 , String num2 ) {
14+ BigInteger multiply = new BigInteger (num1 ).multiply (new BigInteger (num2 ));
15+ return multiply .toString (10 );
16+ }
17+
18+ public static String solution3 (String num1 , String num2 ) {
19+ //TODO
20+ return "" ;
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ package com .examplehub .leetcode .middle ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import static org .junit .jupiter .api .Assertions .*;
6+
7+ class MultiplyStringsTest {
8+ @ Test
9+ void testSolution1 () {
10+ assertEquals ("6" , MultiplyStrings .solution1 ("2" , "3" ));
11+ }
12+ @ Test
13+ void testSolution2 () {
14+ assertEquals ("6" , MultiplyStrings .solution2 ("2" , "3" ));
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments