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/num_subseq_satisfy.cpp | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 other/num_subseq_satisfy.cpp (limited to 'other/num_subseq_satisfy.cpp') diff --git a/other/num_subseq_satisfy.cpp b/other/num_subseq_satisfy.cpp deleted file mode 100644 index 6eb1a12..0000000 --- a/other/num_subseq_satisfy.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// 1498. Number of Subsequences That Satisfy the Given Sum Condition -#include "leetcode.h" - -/* - * given an array of integers 'nums' and an integer 'target' - * return the numbe of non-empty subsequences of 'nums' such - * that the sum of the minimum and maximum element on it is - * less or equal to 'target'. return modulo 10^9+7 - */ - -class Solution { -public: - int numSubSeq(vector &nums, int target) { - int ans = 0, mod = 1000000007; - vector pre = {0, 1}; - for (auto i = pre.size(); i <= nums.size(); ++i) - pre.push_back((pre.back() << 1) % mod); - sort(nums.begin(), nums.end()); - for (int i = 0, j = nums.size() - 1; i <= j; ++i) { - while (i <= j && nums[i] + nums[j] > target) - --j; - ans = (ans + pre[j - i + 1]) % mod; - } - return ans; - } -}; - -int main() { - Solution obj; - vector n1 = {3, 5, 6, 7}, n2 = {3, 3, 6, 8}, n3 = {2, 3, 3, 4, 6, 7}; - printf("%d\n", obj.numSubSeq(n1, 9)); // expect: 4 - printf("%d\n", obj.numSubSeq(n2, 10)); // expect: 6 - printf("%d\n", obj.numSubSeq(n3, 12)); // expect: 61 -} -- cgit v1.2.3