public void Update(int arrMin, int arrValue, int arrIndex) { currSum = currSum + arrValue; if (child != null) { child.Update(arrMin, arrValue, arrIndex); } if (arrValue > 0) { if (currSum >= maxSum) { maxSum = currSum; } if (child == null && isReadyForChild) { child = new ArrValue(arrMin, arrValue, arrIndex); isReadyForChild = false; } } else { interMediateMax.Add(currSum - arrValue); isReadyForChild = true; } }