title: Maximum Subarray Sum Array Created Repeated Concatenation
signature: class Solution {
  
      public Long maximumSubarraySumArrayCreatedRepeatedConcatenation(ArrayList<Integer> a, Integer n, Integer k) {
source_py: def maximum_subarray_sum_array_created_repeated_concatenation(a, n, k):
      max_so_far = (- 2147483648)
      max_ending_here = 0
      for i in range((n * k)):
          max_ending_here = (max_ending_here + a[(i % n)])
          if (max_so_far < max_ending_here):
              max_so_far = max_ending_here
          if (max_ending_here < 0):
              max_ending_here = 0
      return max_so_far
source_cpp: int maximum_subarray_sum_array_created_repeated_concatenation(vector<int> a, int n, int k) {
    int max_so_far = INT_MIN, max_ending_here = 0;
    for ( int i = 0;
    i < n * k;
    i ++ ) {
      max_ending_here = max_ending_here + a [ i % n ];
      if ( max_so_far < max_ending_here ) max_so_far = max_ending_here;
      if ( max_ending_here < 0 ) max_ending_here = 0;
    }
    return max_so_far;
  }
question_info.extension: java
question_info.entry_fn_name: maximumSubarraySumArrayCreatedRepeatedConcatenation
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 15540, "inputs": {"a": [5, 6, 12, 20, 23, 28, 33, 37, 47, 51, 53, 56, 63, 65, 65, 68, 69, 76, 76, 78, 83], "n": 18, "k": 20}}, {"idx": 1, "outputs": 218, "inputs": {"a": [68, 10, 52, -44, 34, -4, -34, 2, 50, -60, 50, 94, -98, -98, -44, -36, -4, -62, -2, -92, -70, -48, -78, -10, 94], "n": 22, "k": 22}}, {"idx": 2, "outputs": 522, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 34, "k": 29}}, {"idx": 3, "outputs": 29070, "inputs": {"a": [71, 59, 21, 82, 73, 29, 30, 25, 21, 10, 85, 22, 60, 43, 49, 20, 34, 39, 69, 6, 44, 27, 50, 33, 57, 29, 65, 18, 68, 56, 50, 28], "n": 23, "k": 30}}, {"idx": 4, "outputs": 18, "inputs": {"a": [-84, -74, -74, -56, -54, -48, -48, -46, -42, -34, -32, -30, -18, -16, -16, 6, 12, 20, 24, 26, 30, 32, 34, 42, 42, 42, 44, 46, 46, 50, 50, 62, 72, 78, 90], "n": 17, "k": 23}}, {"idx": 5, "outputs": 300, "inputs": {"a": [0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0], "n": 16, "k": 25}}, {"idx": 6, "outputs": 2570, "inputs": {"a": [3, 7, 11, 11, 26, 60, 68, 71, 77, 91, 95], "n": 8, "k": 10}}, {"idx": 7, "outputs": 134, "inputs": {"a": [28, 48, -86, -52, 6, 4, 30, 18, -32, 60, -2, 16, -88, -36], "n": 8, "k": 11}}, {"idx": 8, "outputs": -2147483648, "inputs": {"a": [1], "n": 0, "k": 0}}, {"idx": 9, "outputs": -2147483648, "inputs": {"a": [76], "n": 0, "k": 0}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(ArrayList<Integer> a, Integer n, Integer k, Long expected){
          try{
              Driver driver = new Driver();
              if (driver.run(a, n, k,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(new ArrayList<>(Arrays.asList(5, 6, 12, 20, 23, 28, 33, 37, 47, 51, 53, 56, 63, 65, 65, 68, 69, 76, 76, 78, 83)), 18, 20, 15540L);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(68, 10, 52, -44, 34, -4, -34, 2, 50, -60, 50, 94, -98, -98, -44, -36, -4, -62, -2, -92, -70, -48, -78, -10, 94)), 22, 22, 218L);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 34, 29, 522L);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(71, 59, 21, 82, 73, 29, 30, 25, 21, 10, 85, 22, 60, 43, 49, 20, 34, 39, 69, 6, 44, 27, 50, 33, 57, 29, 65, 18, 68, 56, 50, 28)), 23, 30, 29070L);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-84, -74, -74, -56, -54, -48, -48, -46, -42, -34, -32, -30, -18, -16, -16, 6, 12, 20, 24, 26, 30, 32, 34, 42, 42, 42, 44, 46, 46, 50, 50, 62, 72, 78, 90)), 17, 23, 18L);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0)), 16, 25, 300L);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(3, 7, 11, 11, 26, 60, 68, 71, 77, 91, 95)), 8, 10, 2570L);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(28, 48, -86, -52, 6, 4, 30, 18, -32, 60, -2, 16, -88, -36)), 8, 11, 134L);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1)), 0, 0, -2147483648L);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(76)), 0, 0, -2147483648L);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> a, Integer n, Integer k, Long expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(a, n, k),expected);
      }
      
      public boolean validateSolution(Long actual, Long expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__