Understand the approch to solve this problem
Intuition\n Describe your first making a good problem solving skills to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nap
# Intuition\n<!-- Describe your first making a good problem solving skills to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\napproach-> our answer store to max_sum and aprove to abs value and compare the vector ele, of kth ele to add the index add adn push the our queue get answer and lkast subtract to ans which store the queue and return max_sum value\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nbecouse subtract the kth ele in a loop and find the top and insert the queue\nN(logN) + k(log)N\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(k);\n# Code\n```\nclass Solution {\npublic:\n    long long kSum(vector<int>& nums, int k) {\n        // traverse the whole array and get the max and abs value\n        int n = nums.size();\n        long long max_sum = 0;\n        for(int i=0;i<n;i++){\n            max_sum += (long long)max(0,nums[i]);\n            nums[i] = abs(nums[i]);\n        }\n        // sort nums array element\n        sort(nums.begin(),nums.end());\n        vector<long long>value_to_sub = {0};\n        // making queue to store the max value and index of the array\n        priority_queue<pair<long long, int>,vector<pair<long long, int>>,\n            greater<pair<long long, int>>> minCheck;\n            minCheck.push({nums[0] , 0});\n// using loop we travers the nums and get the top ele ans second ele and push to our value \n            while(value_to_sub.size() < k){\n                auto top = minCheck.top();\n                long long value = top.first;\n                int index = top.second;\n\n                minCheck.pop();\n                value_to_sub.push_back(value);\n          \n                if(index < n-1){\n                    minCheck.push({value + nums[index+1],index+1});\n                    minCheck.push({value + nums[index+1] - nums[index],index+1});\n                }\n            }\n// return to get the value and subtract of the maxSum  \n        return max_sum - value_to_sub[k-1];       \n    }\n};\n```
['C++']