leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit 55f537f6393e910be3212e4812560fcd072cd6f3
parent 55ae892793093808585469747344fb139da57a15
author Dimitrije Dobrota <mail@dimitrijedobrota.com>
date Sun, 25 Feb 2024 14:47:53 +0000

Improve UnionFind template Add reset() to return to starting state

Diffstat:
M Templates/Union_Find.cpp | +++++

1 files changed, 5 insertions(+), 0 deletions(-)


diff --git a/ Templates/Union_Find.cpp b/ Templates/Union_Find.cpp

@@ -29,6 +29,11 @@ class UnionFind { size[x] = 0; }
void reset() {
memset(size.data(), 0x00, size.size() * sizeof(int));
iota(begin(root), end(root), 0);
}
int count() const { return cnt; } bool connected(int x, int y) const { return find(x) == find(y); } };