Dsa
Arrays
Medium
Subarray with Largest Sum After Deleting One Element
Given an array of integers, find the maximum sum of a subarray after deleting at most one element. The deleted element may not be the first or last element of the subarray.
Input Format:
- The first line contains an integer N (the number of elements in the array).
- The second line contains N space-separated integers representing the elements of the array.
Output Format:
- Print a single integer representing the maximum sum of the subarray after deleting one element.
Example:
Input:
5
1 -2 0 3 4
Output:
7
Key concepts
arrayssubarraydynamic programming
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now