maxSum and minSum to 0 to store the maximum and minimum subarray sums respectively.currentMax and currentMin to 0 to store the current maximum and minimum subarray sums ending at the current index.nums.
a. Update currentMax by taking the maximum of currentMax + nums[i] and nums[i].
b. Update maxSum by taking the maximum of maxSum and currentMax.
c. If currentMax becomes negative, reset it to 0.
d. Update currentMin by taking the minimum of currentMin + nums[i] and nums[i].
e. Update minSum by taking the minimum of minSum and currentMin.
f. If currentMin becomes positive, reset it to 0.maxSum and minSum.