isPresent of size 10001 (since 1 <= nums[i] <= 10^4).start and end pointers to 0, currentSum to 0, and maxSum to 0.nums using the end pointer.end, check if it is already present in isPresent.currentSum, and update maxSum if currentSum is greater.start pointer to the right, unmarking elements in isPresent and subtracting their values from currentSum until the duplicate element is removed.end has reached the end of nums.maxSum as the result.