Plusle and Minun on Array solution codechef – Chef has an array AA of length NN. He defines the alternating sum of the array as: S=|A1|−|A2|+|A3|−|A4|+…(−1)N−1⋅|AN|S=|A1|−|A2|+|A3|−|A4|+…(−1)N−1⋅|AN|

Plusle and Minun on Array solution codechef Chef has an array AA of length NN. He defines the alternating sum of the array as: S=|A1|−|A2|+|A3|−|A4|+…(−1)N−1⋅|AN|S=|A1|−|A2|+|A3|−|A4|+…(−1)N−1⋅|AN| Chef is allowed to perform the following operation on the array at most once: Choose two indices ii and jj (1≤i<j≤N)(1≤i<j≤N) and swap the elements AiAi and AjAj. Find the maximum alternating sum Chef can achieve by performing the operation at most once. Note: |X||X| denotes the absolute value of XX. … Read more