Skip to content

Commit 3237c5e

Browse files
BarklimBarklim
Barklim
authored and
Barklim
committed
Create 0045.js
1 parent db22a71 commit 3237c5e

File tree

3 files changed

+70
-7
lines changed

3 files changed

+70
-7
lines changed

example/3.Linkedlist/0445.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Definition for singly-linked list.
3+
* function ListNode(val, next) {
4+
* this.val = (val===undefined ? 0 : val)
5+
* this.next = (next===undefined ? null : next)
6+
* }
7+
*/
8+
/**
9+
* @param {ListNode} l1
10+
* @param {ListNode} l2
11+
* @return {ListNode}
12+
*/
13+
var addTwoNumbers = function(l1, l2) {
14+
15+
};
16+
17+
const myLinkedList = new LinkedList();
18+
myLinkedList.prepend(7);
19+
myLinkedList.append(2);
20+
myLinkedList.append(4);
21+
myLinkedList.append(3);
22+
23+
const myLinkedList2 = new LinkedList();
24+
myLinkedList2.prepend(5);
25+
myLinkedList2.append(6);
26+
myLinkedList2.append(4);
27+
28+
const myLinkedList3 = new LinkedList();
29+
myLinkedList3.prepend(0);
30+
31+
const myLinkedList4 = new LinkedList();
32+
myLinkedList4.prepend(0);
33+
34+
const myLinkedList5 = new LinkedList();
35+
myLinkedList5.prepend(1);
36+
myLinkedList5.append(2);
37+
myLinkedList5.append(3);
38+
39+
const myLinkedList6 = new LinkedList();
40+
myLinkedList6.prepend(4);
41+
myLinkedList6.append(5);
42+
myLinkedList6.append(6);
43+
44+
const executeList = (l1, l2) => addTwoNumbers(l1.head, l2.head)
45+
46+
const execute = (l1, l2) => {
47+
console.log('travers')
48+
console.log(l1.toString());
49+
console.log(l2.toString());
50+
const list1 = executeList(l1, l2)
51+
console.log(traversList(list1))
52+
}
53+
54+
execute(myLinkedList, myLinkedList2) // [7,2,4,3] [5,6,4] // [7,8,0,7]
55+
execute(myLinkedList3, myLinkedList4) // [0] [0] // [0] ???
56+
execute(myLinkedList5, myLinkedList6) // [1,2,3] [4,5,6] // [5,7,9]

example/5.Stack/0071.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ var simplifyPath = function(path) {
66

77
};
88

9-
const example1 = isValid("/home/"); // "/home"
10-
const example2 = isValid("/home//foo/"); // "/home/foo"
11-
const example3 = isValid("/home/user/Documents/../Pictures"); // "/home/user/Pictures"
12-
const example4 = isValid("/../"); // "/"
13-
const example5 = isValid("/.../a/../b/c/../d/./"); // "/.../b/d"
9+
const example1 = simplifyPath("/home/"); // "/home"
10+
const example2 = simplifyPath("/home//foo/"); // "/home/foo"
11+
const example3 = simplifyPath("/home/user/Documents/../Pictures"); // "/home/user/Pictures"
12+
const example4 = simplifyPath("/../"); // "/"
13+
const example5 = simplifyPath("/.../a/../b/c/../d/./"); // "/.../b/d"
1414

1515
console.log(example1);
1616
console.log(example2);

example/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Better order to solve problems
4747
- 76. Minimum Window Substring
4848
- 239. Sliding Window Maximum
4949

50-
### [Linked list](https://github.com/Barklim/leetcode-javascript/tree/master/example/3.Linkedlist)
50+
### [3.Linked list](https://github.com/Barklim/leetcode-javascript/tree/master/example/3.Linkedlist)
5151

5252
707. Design Linked List
5353
876. Middle of the Linked List
@@ -66,8 +66,10 @@ Better order to solve problems
6666
287. Find the Duplicate Number
6767
- 23. Merge k Sorted Lists
6868
- 25. Reverse Nodes in k-Group
69+
1.
70+
445. Add Two Numbers II
6971

70-
### [Binary Search](https://github.com/Barklim/leetcode-javascript/tree/master/example/4.BinarySearch)
72+
### [4.Binary Search](https://github.com/Barklim/leetcode-javascript/tree/master/example/4.BinarySearch)
7173

7274
704. Binary Search
7375
- 74. Search a 2D Matrix
@@ -237,6 +239,11 @@ Better order to solve problems
237239
64. Minimum path sum
238240
72. Edit Distance
239241

242+
### Greedy
243+
### Advanced Graphs
244+
### Bit Manipulation
245+
### Math & Geometry
246+
240247
## Programming skills
241248

242249
### [0.Basic](https://github.com/Barklim/leetcode-javascript/tree/master/example/ProgrammingSkills/0.Basic)

0 commit comments

Comments
 (0)