Home » Arrays(Dont Mess With Me) » Kadane Algorithm

// The Aim of the program as the title suggest is to find the largest sum of a contiguous sequence of array elements..
// (array containing at least one positive number)
// For example
// Array {4,-9,3,-2,4,-12} the sequence {3,-2,4} is the continuous sequence with largest sum 5

```
import java.io.*;
public class MaxSubsum
{
public static int MaxSum(int[] array) {
int maxsum = 0;
int sum = 0;
for (int i = 0; i < array.length; i++)
{
sum = sum + array[i];
if (sum > maxsum)
{
maxsum = sum;

}
else if (sum < 0)
{
sum = 0;
}
}
return maxsum;
}
public static void main (String[] args) throws IOException
{
int[] a=new int[25];
int num=0,i=0;
System.out.println("Enter the Number of element");
System.out.println("Enter the array");
for(i=1;i<=num;i++)
{
}
int value = MaxSum(a);
System.out.println("The maximum sub sum is:"+value);
}
}

```

1. Kevin Lee says:

Hi Appit,

Your blog is such a complete read. I like your approach with Kadane Algorithm find if each of the two arrays have the same set of integers. Clearly, you wrote it to make learning a cake walk for me.

We’re currently in an infinite loop between sales and support, neither of whom seem to be able to understand a basic issue. This enables the industry to summon command without putting in the infrastructure at all AWS Training . AWS has several configuration management solutions for AWS scalability, flexibility, availability and management.

We want to purchase some sizeable reserved instances but are told that the only way to pay is all at once with a credit card. No split payments, no offer to pay by check, no offer to pay by ACH, no offer to pay by wire.

Can someone explain to me how AWS serves enterprises if they only accept consumer methods of payment?

Super likes !!! for this amazing post. I thinks everyone should bookmark this.

Kind Regards,
Kevin

2. Hallo There,

I am currently working on a project that does not include storyboards and I am trying to create a user authentication and sign-in method. I was initially going to use FireBase but they did not have Carthage support so I decided to try out AWS. I initially tried using AWSCognitoIdentityProvider framework with my custom UI but the passwordauthentication method for signing in would not trigger a result. I moved onto the AWSAuthUI framework (plus AWSAuthCore, AWSFacebookSignIn, AWSGoogleSignIn, AWSUserPoolsSignIn) with the built in UI but I keep getting the error below before even getting to the login screen.

Anyways great write up, your efforts are much appreciated.

Merci,
Preethi.

### Website

#### arpit tak

I like JAVA . I code. I chill. I blog.I eat. I sleep. I dream.

View Full Profile →