C++ clean code beat 97% with detailed explanation
introduce some pattern firstly,\n\n1. all positive : [1,2,3], k = 3, array_sum = 6\n    return array_sum*3\n\n\n2. all negative : [-1,-2], k = 2, array_sum = -3
**introduce some pattern firstly,**\n```\n1. all positive : [1,2,3], k = 3, array_sum = 6\n    return array_sum*3\n```\n```\n2. all negative : [-1,-2], k = 2, array_sum = -3\n    return 0\n```\n```\n3. hybrid, with array_sum <= 0, [2,1,-3], k = 4, array_sum = 0\n       [ 2,  1, -3, 2, 1, -3, 2, 1, -3, 2, 1, -3]\nmax sum  2   3  0   2  3  0   2  3   0   2  3  0\n\treturn max_subarray_sum between [2,1,-3,2,1,-3] which is twice of original array\n\tso, return max_subarray_sum = 3\n```\n```\n4. hybrid, with array_sum > 0, [2,-6,5], k =4, array_sum = 1\n       [ 2, -6, 5, 2, -6, 5, 2, -6, 5, 2, -6, 5]\nmax sum  2   0  5  7   1  6  8   2  7  9   3  8\na. you can notice max subarray sum is getting bigger as k grows up.\nb. with first 2 array, we can get max subarray sum is 8.\nc. after that, with each new array, max_subarray_sum will increase by 1, which is array_sum\n==>return (max_subarray_sum when k=2) + array_sum*(k-2)\n```\n\n# formula : \n`return ((max_subarray_sum when k = 2) + (array_sum>0?array_sum*(k-2):0))%1000000007`\n\n```\nclass Solution {\npublic:\n    int kConcatenationMaxSum(vector<int>& arr, int k) {\n\t    /* get array sum */\n        long long array_sum = accumulate(arr.begin(),arr.end(),0);\n\t\t\n\t\t/* generate two times arr */\n        vector<int> arr_cascade(arr.begin(),arr.end());\n        arr_cascade.insert(arr_cascade.begin(),arr.begin(),arr.end());\n        long long max_subarray_sum = 0, tmp_sum = 0;\n\t\t\n\t\t/* calculate max_subarray_sum */\n        for(int i = 0 ; i < arr_cascade.size() ; i++){\n            tmp_sum = max(tmp_sum+(long long)arr_cascade[i],(long long)arr_cascade[i]);\n            max_subarray_sum = max(max_subarray_sum,tmp_sum);\n        }\n        return (max_subarray_sum+(array_sum>0?array_sum*(k-2):0))%1000000007;\n    }\n};\n```
[]