diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/non_decreasing_subseq.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/non_decreasing_subseq.cpp')
-rw-r--r-- | other/non_decreasing_subseq.cpp | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/other/non_decreasing_subseq.cpp b/other/non_decreasing_subseq.cpp deleted file mode 100644 index b94510f..0000000 --- a/other/non_decreasing_subseq.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// 491. Non-decreasing Subsequences -#include "leetcode.h" - -/* - * given: integer array 'nums' - * return: all possible different non-decreasing subsequences - * of given array with at least two elements. return value - * can be in any order - */ - -class Solution { -public: - vector<vector<int>> findSubsequences(vector<int> &nums) { - set<vector<int>> seqs = {vector<int>(0)}; - for (int i = 0; i < nums.size(); i++) { - vector<vector<int>> built(seqs.size()); - copy(seqs.begin(), seqs.end(), built.begin()); - for (auto s : built) - if (s.empty() || nums[i] >= s.back()) { - s.push_back(nums[i]); - seqs.insert(s); - } - } - vector<vector<int>> ans; - for (auto s : seqs) - if (s.size() > 1) - ans.push_back(s); - return ans; - } -}; - -int main() { - Solution obj; - vector<int> n1 = {4, 6, 7, 7}, n2 = {4, 4, 3, 2, 1}; - for (auto i : obj.findSubsequences(n1)) { - for (auto j : i) - printf("%d ", j); - printf("\n"); - } - printf("\n"); - for (auto i : obj.findSubsequences(n2)) { - for (auto j : i) - printf("%d ", j); - printf("\n"); - } -} |