From a557fa36a22c5ef4a29da596ee1e3aa10be55984 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 27 Sep 2021 20:00:08 +0800 Subject: import(solutions): ... --- works/solutions/leetcode/cpp/15.cpp | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 works/solutions/leetcode/cpp/15.cpp (limited to 'works/solutions/leetcode/cpp/15.cpp') diff --git a/works/solutions/leetcode/cpp/15.cpp b/works/solutions/leetcode/cpp/15.cpp new file mode 100644 index 0000000..2b8f6cd --- /dev/null +++ b/works/solutions/leetcode/cpp/15.cpp @@ -0,0 +1,44 @@ +#include +#include + +using std::vector; + +#include +#include +#include +#include + +bool operator<(const std::vector &l, std::vector &r) { + return std::lexicographical_compare(l.cbegin(), l.cend(), r.cbegin(), + r.cend()); +} + +class Solution { +public: + int ha[100010]{0}; + + vector> threeSum(vector &nums) { + std::set> result; + + if (nums.size() < 3) + return {}; + + std::unordered_map m; + + for (auto n : nums) { + if (n >= 0) + m[n]++; + } + + for (int i = 0; i < nums.size() - 2; i++) { + for (int j = i + 1; j < nums.size() - 1; j++) { + auto v = -nums[i] - nums[j]; + if (v == 0) { + + } + } + } + + return std::vector>(result.cbegin(), result.cend()); + } +}; \ No newline at end of file -- cgit v1.2.3