Skip to content

Commit 0fb5f05

Browse files
committed
feat: 两数相加
1 parent 2a5f475 commit 0fb5f05

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {ListNode} l1
3+
* @param {ListNode} l2
4+
* @return {ListNode}
5+
*/
6+
var addTwoNumbers = function(l1, l2) {
7+
const l1Num = Number(l1.reverse().join(''));
8+
const l2Num = Number(l2.reverse().join(''));
9+
10+
const sum = l1Num + l2Num;
11+
12+
return sum.toString().split('').map(item => Number(item));
13+
};
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
11+
</body>
12+
<script src="./addTwoNumbers.js"></script>
13+
</html>

0 commit comments

Comments
 (0)