6ms Java-Dp Solutipn
java code is:\n# \n\nclass Solution {\n    int mod=(int)1e9+7;\n    long findMax(int arr[]){\n        int n=arr.length;\n        long last=0;\n        long max=
java code is:\n# \n```\nclass Solution {\n    int mod=(int)1e9+7;\n    long findMax(int arr[]){\n        int n=arr.length;\n        long last=0;\n        long max=last=Math.max(0,arr[0]);\n        for(int i=1;i<n;i++)\n            max=Math.max(max,last=Math.max(last+arr[i],arr[i]));\n        return Math.max(0,max);\n    }\n    long findMaxTail(int arr[]){\n        int n=arr.length;\n        long last=Math.max(arr[0],0);\n        for(int i=1;i<n;i++)\n            last=Math.max(last+arr[i],arr[i]);\n        return Math.max(last,0);\n    }\n    long findMaxHead(int arr[]){\n        int n=arr.length;\n        long last=Math.max(0,arr[n-1]);\n        for(int i=n-2;i>=0;i--) last=Math.max(last+arr[i],arr[i]);\n        return Math.max(last,0);\n    }\n    long findSum(int arr[],int i){\n        if(i>=arr.length)return 0;\n        return arr[i]+findSum(arr,i+1);\n    }\n    public int kConcatenationMaxSum(int[] arr, int k) {\n         long max=findMax(arr);\n        if(k==1)return (int)(max%mod);\n      long sum=findSum(arr,0);\n      long head=findMaxHead(arr);\n      long tail=findMaxTail(arr);\n        long tempAns=Math.max(max,(head+tail)); \n        return (int)(Math.max(tempAns,(tail+(k-2)*sum+head))%1000000007);\n        \n    }\n}\n```\n**Please,Upvote if this is helpful**
[]