Swift solution
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    func maximumValueSum(_ nums: [Int], _ k: Int, _: [[Int]]) -> Int {\n        var minPositiveDiff: Int = .max\n        var maxNegativeDiff: Int = .min\n        var changedSum: Int = .zero\n        var increasedNumCount: Int = .zero\n        for num in nums {\n            let changedNum = num ^ k\n            let diff = changedNum - num\n\n            if diff > .zero {\n                increasedNumCount += 1\n                minPositiveDiff = min(minPositiveDiff, diff)\n                changedSum += changedNum\n            } else {\n                maxNegativeDiff = max(maxNegativeDiff, diff)\n                changedSum += num\n            }\n        }\n\n        if increasedNumCount % 2 == .zero {\n            return changedSum\n        } else {\n            return max(changedSum - minPositiveDiff, changedSum + maxNegativeDiff)\n        }\n    }\n}\n```
['Array', 'Greedy', 'Bit Manipulation', 'Tree', 'Swift']