JAVA simple solution using Priority Queue.
Intuition\n Describe your first thoughts on how to solve this problem. \nWe are given to replace an element at index "i" with it\'s negative value . If we someh
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe are given to replace an element at index "i" with it\'s negative value . If we somehow got to find the minimum number in the given array then we can easily replace it with it\'s negative value.so we can think about a priority queue.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Create a minimum priority queue(pq).\n2. Initialize a sum variable with zero("0").\n3. Interate over nums array ,add elements of nums into pq and store the sum of each elements in sum variable;\n4. Iterate a **while loop for k not equal to zero as well as pq will not be empty**.\n5. Remove element from priority queue\n-  (I)if the element is negative then intitialize a variable and store it\'s negative,then add twice that variable to the sum.\n- (II)if the element is positive then subtract it twice from the sum.\n- After I & II again put back negative of that element into pq.\n6.the return the sum variable.  \n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N) , N==nums.length;\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N) , For creating a PriorityQueue.\n# Code\n```\nclass Solution {\n    public int largestSumAfterKNegations(int[] nums, int k) {\n        PriorityQueue<Integer> pq=new PriorityQueue<>();\n        int sum=0;\n        for(int i=0;i<nums.length;i++)\n        {\n            pq.add(nums[i]);\n            sum+=nums[i];\n        }\n        while(k!=0&&!pq.isEmpty())\n        {\n            int x=pq.remove();\n            if(x<0){\n                int y=-x;\n                sum=sum+y+y;\n            }\n            else{\n                sum=sum-x-x;\n            }\n            pq.add(-x);\n            k--;\n        }\n        return sum;\n    }\n}\n```
['Java']