Class Solution
java.lang.Object
g1101_1200.s1191_k_concatenation_maximum_sum.Solution
1191 - K-Concatenation Maximum Sum.<p>Medium</p>
<p>Given an integer array <code>arr</code> and an integer <code>k</code>, modify the array by repeating it <code>k</code> times.</p>
<p>For example, if <code>arr = [1, 2]</code> and <code>k = 3</code> then the modified array will be <code>[1, 2, 1, 2, 1, 2]</code>.</p>
<p>Return the maximum sub-array sum in the modified array. Note that the length of the sub-array can be <code>0</code> and its sum in that case is <code>0</code>.</p>
<p>As the answer can be very large, return the answer <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> arr = [1,2], k = 3</p>
<p><strong>Output:</strong> 9</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> arr = [1,-2,1], k = 5</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> arr = [-1,-2], k = 7</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= arr.length <= 10<sup>5</sup></code></li>
<li><code>1 <= k <= 10<sup>5</sup></code></li>
<li><code>-10<sup>4</sup> <= arr[i] <= 10<sup>4</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
kConcatenationMaxSum
public int kConcatenationMaxSum(int[] arr, int k)
-