Techno Blender
Digitally Yours.
Browsing Tag

subtracting

Minimize absolute Sum by subtracting one and two from adjacent indices

Given an arr of length N, the task is to find the smallest possible sum of the array when we can subtract 1 and 2 respectively from two adjacent indices any number of times.Examples:Input: N = 1, arr = { -45 }Output: 45Explanation: As there are no consecutive indices present, Therefore, operation can’t be performed, and the smallest possible value of absolute sum is 45.Input: N = 3, arr = {4,  6, -1}Output: 2Explanation:First Operation: Chose adjacent indices are 1, 2: {A1 – 1, A2 – 2, A3} = {3, 4, -1}Second Operation:…