Skip to content

Commit 2b6b72e

Browse files
linkedlist
1 parent 1324d9d commit 2b6b72e

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const getIntersectionNode = (headA, headB) => {
2+
let ptrA = headA;
3+
let ptrB = headB;
4+
5+
while (ptrA !== ptrB) {
6+
ptrA = ptrA !== null ? ptrA.next : headB;
7+
ptrB = ptrB !== null ? ptrB.next : headA;
8+
}
9+
10+
return (ptrA === ptrB && ptrA !== null) ? ptrA : null;
11+
}

exercises/leetcode/maxPathSumBinaryTree.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* Given a non-empty binary tree, find the maximum path sum.
33
4-
For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at least one node and does not need to go through the root.
4+
For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections.
5+
The path must contain at least one node and does not need to go through the root.
56
67
Example 1:
78

exercises/leetcode/setZeroes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ const setZeroes = matrix => {
5555
}
5656
}
5757

58-
for (let i = 0; i < rows; i++) {
59-
for (let j = 0; j < columns; j++) {
58+
for (let i = 1; i < rows; i++) {
59+
for (let j = 1; j < columns; j++) {
6060
if (matrix[i][0] === 0 || matrix[0][j] === 0) {
6161
matrix[i][j] = 0;
6262
}

0 commit comments

Comments
 (0)