Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3891fdd

Browse files
authored
Batch-5/Neetcode-250/Added-articles (#3799)
1 parent d750e95 commit 3891fdd

8 files changed

+4078
-8
lines changed

articles/build-a-matrix-with-conditions.md

Lines changed: 526 additions & 0 deletions
Large diffs are not rendered by default.

articles/car-pooling.md

Lines changed: 469 additions & 0 deletions
Large diffs are not rendered by default.

articles/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -578,28 +578,28 @@ class UnionFind {
578578
* @param {number} n
579579
*/
580580
constructor(n) {
581-
this.n = n;
582581
this.Parent = Array.from({ length: n + 1 }, (_, i) => i);
583582
this.Size = Array(n + 1).fill(1);
583+
this.n = n;
584584
}
585585
586586
/**
587-
* @param {number} v1
587+
* @param {number} node
588588
* @return {number}
589589
*/
590-
find(v1) {
590+
find(node) {
591591
if (this.Parent[node] !== node) {
592592
this.Parent[node] = this.find(this.Parent[node]);
593593
}
594594
return this.Parent[node];
595595
}
596596
597597
/**
598-
* @param {number} v1
599-
* @param {number} v2
598+
* @param {number} u
599+
* @param {number} v
600600
* @return {boolean}
601601
*/
602-
union(v1, v2) {
602+
union(u, v) {
603603
let pu = this.find(u);
604604
let pv = this.find(v);
605605
if (pu === pv) return false;
@@ -612,6 +612,9 @@ class UnionFind {
612612
return true;
613613
}
614614
615+
/**
616+
* @return {number}
617+
*/
615618
isConnected() {
616619
return this.n === 1;
617620
}
@@ -960,8 +963,6 @@ class Solution:
960963
if edges[i][2] == edges[ind][2]:
961964
pseudo.add(i)
962965
pseudo.add(ind)
963-
mstEdge.add(i)
964-
mstEdge.add(ind)
965966

966967
return [list(mstEdge - pseudo), list(pseudo)]
967968
```

0 commit comments

Comments
 (0)