From 3fb7c796f40b69e85b9c80b07e575120a83d15c0 Mon Sep 17 00:00:00 2001 From: SquidSpirit Date: Mon, 10 Mar 2025 23:50:24 +0800 Subject: [PATCH] feat: 47_permutations_2 --- 47_permutations_2/main.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 47_permutations_2/main.cpp diff --git a/47_permutations_2/main.cpp b/47_permutations_2/main.cpp new file mode 100644 index 0000000..f7aaab7 --- /dev/null +++ b/47_permutations_2/main.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; + +class Solution { + public: + vector> permuteUnique(vector& nums) { + vector> result; + + sort(nums.begin(), nums.end()); + result.emplace_back(nums); + + while (next_permutation(nums.begin(), nums.end())) { + result.emplace_back(nums); + } + return result; + } +}; \ No newline at end of file