Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
PRATHAP KUDUPU
authored and
PRATHAP KUDUPU
committed
May 12, 2017
1 parent
7474f2d
commit 9bcf94f
Showing
6 changed files
with
63 additions
and
16 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package Algorithms.Arrays; | ||
|
||
public class MaximumSubArray { | ||
public static int get(int arr []) | ||
{ | ||
int maxsoFar=arr[0], maxEndingHere=arr[0]; | ||
for (int i=1;i<arr.length;i++) | ||
{ | ||
//Get the max in the iteration | ||
maxEndingHere=Math.max(maxEndingHere+arr[i], arr[i]); | ||
//Get the max so far | ||
maxsoFar=Math.max(maxEndingHere, maxsoFar); | ||
|
||
} | ||
return maxsoFar; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters