WEEB EXPLAINS PYTHON SOLUTION
\n\n\t\n\tclass Solution:\n\t\tdef largestSumAfterKNegations(self, A: List[int], K: int) -> int:\n\t\t\tA.sort()\n\t\t\ti = 0\n\t\t\twhile i < len(A) and K>0:\n
![image](https://assets.leetcode.com/users/images/deac20d6-f25b-4f9f-9a91-4f79bcb66724_1620122556.4046779.png)\n\n\t\n\tclass Solution:\n\t\tdef largestSumAfterKNegations(self, A: List[int], K: int) -> int:\n\t\t\tA.sort()\n\t\t\ti = 0\n\t\t\twhile i < len(A) and K>0:\n\t\t\t\tif A[i] < 0: # negative value\n\t\t\t\t\tA[i] = A[i] * -1 # update the list, change negative to positive\n\t\t\t\t\tK-=1\n\n\t\t\t\telif A[i] > 0: # positive value\n\t\t\t\t\tif K % 2 == 0: # let K==2(must be even value), this means -1*-1==1 so it has no effect on sum\n\t\t\t\t\t\treturn sum(A)\n\t\t\t\t\telse: return sum(A) - 2 * min(A) # let A==[1,2,3],K=1, so equation is 6-2(1)==4, same as -1+2+3=4 after taking the minimum in the list to give the largest possible sum required in the question\n\n\t\t\t\telse: return sum(A) # if A[i]==0,just sum cuz 0 is neutral: 1-0==1 or 1+0==1 thus no change just sum\n\n\t\t\t\ti+=1\n\n\t\t\tif K > len(A): # that means we have changed all values to positive\n\t\t\t\tA.sort() # cuz now its the opposite let A = [-4,-2,-3], K = 8, now flipping all negatives to positives, we have a new minimum which is 2\n\t\t\t\tif K % 2 == 0: # Here onwards is basically the same thing from before\n\t\t\t\t\treturn sum(A)\n\t\t\t\telse: return sum(A) - 2 * min(A)\n\n\t\t\treturn sum(A)\n\nAight, time for some anime recommendations\n# try watching ***Uzaki-chan Wants to Hang Out!***\n# Genres: Romantic comedy, Slice of life\n# Episodes: 12\n\nOverall, this anime is quite fun to watch. Although i have to warn you, this anime does contain some ecchi(perverted) elements in it, but its not extreme.\n\nNow go take a break and watch some anime.\n
['Python', 'Python3']