Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

• Find the maximal of maximum sum of contiguous subarray by deleting no more than one elemnent?

• 0
• 0
• 0
• 1
• 0
• 0
• 0
• 371

You're given an array of N integer numbers.
The maximal sum of the array is the maximal sum of the elements of a nonempty consecutive subarray of this array. For example, the maximal sum of the array [1, -2, 3, -2, 5] is 6 because the sum of the subarray [3, -2, 5] is 6 and it is impossible to achieve greater subarray sum.
Now you're allowed to remove no more than one element from the given array. What is the maximal possible maximal sum of the resulting array you can achieve by doing so?

• over 4 years ago

Hi utkarsh , I've implemented the solution for above problem in C# ...

using System;

using System.Collections;

class Program

{

```static ArrayList mainList = new ArrayList();

static void Main(){
int []arr = new int[]{1, -2, 3, -2, 5};

for(int i = 0; i < arr.Length; i++){
int count = i + 1;
ArrayList temp = new ArrayList();
for(int j = i; j < arr.Length ; j++){
for(int  k = i; k< count ; k++){
}
count ++;
temp.Clear();
}
}
ShowContents();
}

static void ShowContents(){
float  sum = int.MinValue, pos;

for (int i = 0; i < mainList.Count ; i++){
ArrayList  arr = (ArrayList)mainList[i];
int s = 0;
for(int j = 0; j< arr.Count; j++){
s += (int)arr[j];
}
if(sum < s){
sum = s;
}
}
Console.Write("Maximum is : " + sum);
}
```

}

OR
OR
Register

OR
Fill out the form below and instructions to reset your password will be emailed to you:

• Hire
• Post Projects

Post Projects

• All at 0 Cost ....
• Post Tech Job
• Select Best Bidder
• Track the Project
• Approve Work and Pay safely
• Browse Nerds
• Work
• Find Projects Find Projects
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...
• Manage
• Company Company

Manage Company

• All at 0 Cost ....
• Manage Company and Employee Profiles
• Company wide Employee Productivity Reports
• Knowledge Sharing and Collaboration Tools
• Get Sales Lead and Bid for Tech Projects
• Send Invoices and Receive Payment Safely
• Learn
• Nerd Digest Nerd Digest
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...
• Tech Q & A Tech Q & A
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
View more...
View less...