K-Concatenation Maximum Sum
------------------- Easy Java Solution -------------------\n\n# Code\n\nclass Solution {\n      public static long solution(int[] arr, int k, long sum){\n      
------------------- Easy Java Solution -------------------\n\n# Code\n```\nclass Solution {\n      public static long solution(int[] arr, int k, long sum){\n        if(k == 1){\n            return kadanesForOne(arr);\n        }\n        if(sum > 0){\n            return  kadanesForTwo(arr) + ((k - 2) * (sum));\n        }else{\n            return kadanesForTwo(arr);\n        }\n    }\n\n    public static long kadanesForOne(int[] arr) {\n        long finalans = arr[0];\n        long curr = arr[0];\n        for(int i = 1 ; i < arr.length; i++){\n            curr = Math.max(arr[i], arr[i] + curr);\n            finalans = Math.max(finalans, curr);\n        }\n        return finalans; \n    }\n\n    public static long kadanesForTwo(int[] arr) {\n        long finalans = arr[0];\n        long curr = arr[0];\n        for(int i = 1 ; i < 2 * arr.length; i++){\n            curr = Math.max(arr[i % arr.length], arr[i % arr.length] + curr);\n            finalans = Math.max(finalans, curr);\n        }\n        return finalans; \n    }\n    public int kConcatenationMaxSum(int[] arr, int k) {\n        long sum = 0;\n        for (int i = 0; i < arr.length; i++) {\n            sum += arr[i];\n        }\n        sum=sum%1000000007;\n        int sol=(int)(solution(arr, k, sum)%1000000007);\n       return sol==-1?0:sol;\n    }\n}\n```
['Java']