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/sum_subset_xor.cpp | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 other/sum_subset_xor.cpp (limited to 'other/sum_subset_xor.cpp') diff --git a/other/sum_subset_xor.cpp b/other/sum_subset_xor.cpp deleted file mode 100644 index a3048f7..0000000 --- a/other/sum_subset_xor.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "leetcode.h" - -/* - 000 => {empty set} - 001 => {set with only first element} - 010 => {set with only second element} - 011 => {set with first and second element} - 100 ... and so on - 101 - 110 - 111 => {subset with all three elements} -*/ - -class Solution { -public: - int subsetXORSum(vector &nums) { - int n = nums.size(), subsetNum = pow(2, n), ans = 0; - for (int i = 1; i < subsetNum; ++i) { - int runningXOR = 0; - for (int j = 0, bits = i; j < nums.size(); ++j, bits >>= 1) - if (bits & 1) - runningXOR ^= nums[j]; - ans += runningXOR; - } - return ans; - } -}; - -int main() { - vector nums = {3, 4, 5, 6, 7, 8}; - Solution obj; - cout << obj.subsetXORSum(nums); -} -- cgit v1.2.3