C#public int MaxSubArray(int[] nums) { //declarations int globalMax = 0; int currentMax = 0; //validation if(nums.Length == 1) return nums[0]; //logic for(int i = 0; i < nums.Length ; i++) { currentMax += nums[i]; globalMax = Math.Max(currentMax, globalMax); if(currentMax < 0) { currentMax = 0; } } return globalMax; }