| 3 | import java.util.*; |
| 4 | |
| 5 | class Kadane |
| 6 | { |
| 7 | public static void main (String[] args) |
| 8 | { |
| 9 | int [] a = {10,13,11,22,34,50,20,80}; |
| 10 | System.out.println("Sub array with maximum sum is " +maxSubArray(a)); |
| 11 | |
| 12 | } |
| 13 | |
| 14 | static int maxSubArray(int a[]) |
| 15 | { |
| 16 | int l = a.length; |
| 17 | int max = Integer.MIN_VALUE, max_ending = 0; |
| 18 | for (int i = 0; i < l; i++) |
| 19 | { |
| 20 | max_ending = max_ending + a[i]; |
| 21 | if (max < max_ending) |
| 22 | max = max_ending; |
| 23 | if (max_ending < 0) |
| 24 | max_ending = 0; |
| 25 | } |
| 26 | return max; |
| 27 | } |
| 28 | } |
nothing calls this directly
no outgoing calls
no test coverage detected