From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/possible_bipartition.cpp | 45 ------------------------------------------ 1 file changed, 45 deletions(-) delete mode 100644 other/possible_bipartition.cpp (limited to 'other/possible_bipartition.cpp') diff --git a/other/possible_bipartition.cpp b/other/possible_bipartition.cpp deleted file mode 100644 index 6dd4175..0000000 --- a/other/possible_bipartition.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - bool possibleBipartition(int n, vvd & dislikes) { - enum color { green = -1, uncolored, blue }; - if (n == 1 || dislikes.size() == 0) - return true; - unordered_map> dislikeTable; - unordered_map colorTable; - function helper; - helper = [&](int personID, int color) -> bool { - colorTable[personID] = color; - for (const int &other : dislikeTable[personID]) { - if (colorTable[other] == color) - return false; - if (colorTable[other] == uncolored && (!helper(other, -color))) - return false; - } - return true; - }; - for (const auto &relation : dislikes) { - int p1 = relation[0], p2 = relation[1]; - dislikeTable[p1].emplace_back(p2); - dislikeTable[p2].emplace_back(p1); - } - for (int i = 1; i <= n; i++) - if (colorTable[i] == uncolored && (!helper(i, blue))) - return false; - return true; - } -}; - -int main() { - Solution obj; - vvd dislikes1 = {{1, 2}, {1, 3}, {2, 4}}, - dislikes2 = {{1, 2}, {1, 3}, {2, 3}}, - dislikes3 = {{1, 2}, {2, 3}, {3, 4}, {4, 5}, {1, 5}}; - testBool(obj.possibleBipartition(4, dislikes1)); - // true: [2,3] [1,4] - testBool(obj.possibleBipartition(3, dislikes2)); - // false - testBool(obj.possibleBipartition(5, dislikes3)); - // false -} -- cgit v1.2.3