C++ Solved in 3 cases
3 cases :\n  k=1 :  kadane for one\n  sum>0 : kadane for two  + (k-2) kadane for one  \n  sum<0 : kadane for one\n  Expanation:\n  sum>0 : kadane for two  + (k-
3 cases :\n*  k=1 :  kadane for one\n*  sum>0 : kadane for two  + (k-2)* kadane for one  \n*  sum<0 : kadane for one\n  Expanation:\n  sum>0 : kadane for two  + (k-2)* kadane for one  :\n  \n  If sum>0, we need to add it to result because it increases our sum.\n  But for first array  if we have have negative elements in beginning, remove those.\n  :: kadane for two will remove those negative elements \n  :: kadane for one will not work because it will not ensure that sum from 1 array includes last element or not, \n  if not then we can cannot include sum>0 of all arrray, that would decrease overall sum.\n```\n class Solution {\npublic:\n    long long N=1000000007;\n    int kConcatenationMaxSum(vector<int>& arr, int k) {\n        int n=arr.size();\n        int  ans=0;\n        long long sum=0;\n        for (int i = 0; i < n; i++) {\n            sum += arr[i];\n        }\n         if(k == 1){\n            ans= (kadanesForOne(arr,n))%N;\n        }\n        else if(sum > 0){\n            ans= (kadanesForTwo(arr,n) + ((k - 2) * (sum)))%N;\n        }else{\n            ans= (kadanesForTwo(arr,n))%N;\n        }\n        if(ans<0)return 0;\n        return ans%N;\n    }\n     int kadanesForOne(vector<int> arr, int n) {\n        int finalans = arr[0];\n        int curr = arr[0];\n        for(int i = 1 ; i < n; i++){\n            curr = max(arr[i], arr[i] + curr);\n            finalans = max(finalans, curr);\n        }\n        return finalans; \n    }\n    int kadanesForTwo(vector<int> arr, int n) {\n        int finalans = arr[0];\n        int curr = arr[0];\n        for(int i = 1 ; i < 2 * n; i++){\n            curr = max(arr[i % n], arr[i % n] + curr);\n            finalans = max(finalans, curr);\n        }\n        return finalans; \n    }\n};\n             \n               \n```\nHope it helps.\n  \n\n\n
['C']