Java | Easy Solution | Kadanes Variation
\nclass Solution {\n    public long kadane (int arr[]) {\n    long curr = arr[0];\n    long max = arr[0];\n    for(int i = 1; i < arr.length; i++) {\n        if
```\nclass Solution {\n    public long kadane (int arr[]) {\n    long curr = arr[0];\n    long max = arr[0];\n    for(int i = 1; i < arr.length; i++) {\n        if (curr >= 0) curr+=arr[i];\n        else curr = arr[i];\n        if (curr > max) max = curr;\n    }\n    return max;\n}\npublic long kadaneTwo(int arr[]) {\n    int narr[] = new int[arr.length * 2];\n    for (int i = 0; i < arr.length; i++) \n        narr[i] = arr[i];\n    for (int i = 0; i < arr.length; i++)\n        narr[i + arr.length] = arr[i];\n    return kadane(narr);\n}\npublic long sum(int arr[]) {\n    long s = 0;\n    for (int i = 0; i < arr.length; i++)\n        s += arr[i];\n    return s;\n}\npublic int kConcatenationMaxSum(int[] arr, int k) {\n    long sum = sum(arr);\n    long res = 0;\n    long x = 1000000007;\n    if (k == 1) res = kadane(arr);\n    else if (sum < 0) res = kadaneTwo(arr);\n    else res = kadaneTwo(arr) + (k - 2)*sum;\n    if (res < 0) return 0;\n    return (int)(res % x);\n}\n}\n\n```
[]