✅✅Beats 92.22% || 🚀🚀5-Line Code || 🙏🙏💕JAI SHREE SHYAM💕🙏🙏 ||
Intuition\n\n \n\n\n# Code\n```\nclass Solution {\npublic:\n    int kConcatenationMaxSum(vector& arr, int k) {\n        int max_sum = 0, n = arr.size();\n      
# Intuition\n![Screenshot 2024-04-13 115307.png](https://assets.leetcode.com/users/images/b74da014-e47d-43de-bcbb-c2d5ef2697b0_1712989475.107679.png)\n \n![Screenshot 2024-03-02 181759.png](https://assets.leetcode.com/users/images/9649a946-ddf1-4000-817a-6dd3f189fca7_1712989491.888037.png)\n\n# Code\n```\nclass Solution {\npublic:\n    int kConcatenationMaxSum(vector<int>& arr, int k) {\n        int max_sum = 0, n = arr.size();\n        for(auto i = 0, sum = 0; i < n*min(2,k); i++){\n            sum = max(sum + arr[i % n], arr[i % n]);\n            max_sum = max(max_sum, sum);\n        }\n        return ((long long)max_sum + max(0ll, accumulate(arr.begin(), arr.end(), 0ll)* max(0, k - 2))) % 1000000007;\n    }\n};\n
['Array', 'Dynamic Programming', 'C++']