JAVA || 90% || EASY || KADANE || with comments
\t\t 3cases \n\t\t 1) if k==1 return kadane of array\n\t\t 2) if sum of array>0 return kadane of 2 array + sum(k-2)\n\t\t 3) if sum < 0 return kadane of 2 array
\t\t 3cases \n\t\t 1) if k==1 return kadane of array\n\t\t 2) if sum of array>0 return kadane of 2 array + sum*(k-2)\n\t\t 3) if sum < 0 return kadane of 2 array\n\t\t \n\t\t \n\t\t public int kConcatenationMaxSum(int[] arr, int k) {\n\t\t //case 1 when k==1\n\t\t\tif(k==1)\n\t\t\t\treturn kadanes(arr);\n\t\t\t\t\n\t\t\tlong sum=0;\n\t\t\tfor(int ele:arr)\n\t\t\t\tsum+=ele;\n\t\t\t\t\n\t\t\tint[] kd=new int[2*arr.length];\n\t\t\t\n\t\t\tfor(int i=0;i<kd.length;i++)\n\t\t\t\tkd[i]=arr[i%arr.length];\n\t\t\t\t\n\t\t\tlong ans=0;\n\t\t\t\n\t\t\tif(sum<=0){            //case 2\n\t\t\t\t ans= kadanes(kd);\n\t\t\t}else{                      //case 3\n\t\t\t\tans= kadanes(kd)+(k-2)*sum;\n\t\t\t}\n\t\t\tif(ans<0)\n\t\t\t\treturn 0;\n\t\t\treturn (int)(ans%(1000000007));\n\t\t}\n\t\t\n\t\t// basic kadane code\n\t\t\n\t\tpublic int kadanes(int[] arr){\n\t\t\tint sum=0,ans=Integer.MIN_VALUE;\n\t\t\tfor(int ele:arr){\n\t\t\t\tsum+=ele;\n\t\t\t\tif(ans<sum)\n\t\t\t\t\tans=sum;\n\t\t\t\tif(sum<0)\n\t\t\t\t\tsum=0;\n\t\t\t}\n\t\t\treturn ans;\n\t\t}
[]