title: Largest Sum Contiguous Subarray 2
signature: fun largestSumContiguousSubarray2(a: ArrayList<Int>, size: Int): Int {
source_py: def largest_sum_contiguous_subarray_2(a, size):
      max_so_far = a[0]
      curr_max = a[0]
      for i in range(1, size):
          curr_max = max(a[i], (curr_max + a[i]))
          max_so_far = max(max_so_far, curr_max)
      return max_so_far
source_cpp: int largest_sum_contiguous_subarray_2(vector<int> a, int size) {
    int max_so_far = a [ 0 ];
    int curr_max = a [ 0 ];
    for ( int i = 1;
    i < size;
    i ++ ) {
      curr_max = max ( a [ i ], curr_max + a [ i ] );
      max_so_far = max ( max_so_far, curr_max );
    }
    return max_so_far;
  }
question_info.test_list: [{"idx": 0, "outputs": 1265, "inputs": {"a": [1, 3, 4, 7, 8, 8, 10, 12, 16, 19, 19, 20, 20, 21, 21, 22, 26, 27, 29, 34, 36, 38, 38, 39, 41, 43, 44, 47, 47, 49, 57, 57, 60, 62, 63, 65, 75, 77, 77, 78, 81, 82, 82, 83, 83, 84, 85, 98, 99], "size": 38}}, {"idx": 1, "outputs": 90, "inputs": {"a": [-40, 14, 2, -70, 86, -90, -50, -54, -2, 90, 30], "size": 10}}, {"idx": 2, "outputs": 11, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "size": 18}}, {"idx": 3, "outputs": 1063, "inputs": {"a": [60, 69, 41, 7, 77, 36, 36, 26, 35, 30, 64, 75, 3, 35, 60, 71, 29, 47, 15, 29, 43, 88, 56, 22, 9, 45, 40, 50, 52], "size": 25}}, {"idx": 4, "outputs": 348, "inputs": {"a": [-96, -88, -80, -72, -64, -64, -60, -60, -60, -58, -56, -54, -54, -50, -50, -26, -26, -24, -20, -8, -2, 0, 4, 4, 12, 14, 18, 18, 24, 32, 42, 44, 44, 44, 48, 50, 50, 56, 60, 60, 70, 80, 88, 88, 90, 98], "size": 35}}, {"idx": 5, "outputs": 13, "inputs": {"a": [0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0], "size": 22}}, {"idx": 6, "outputs": 1306, "inputs": {"a": [2, 4, 4, 5, 6, 7, 11, 12, 14, 18, 23, 24, 27, 28, 33, 36, 37, 38, 39, 40, 41, 41, 48, 48, 52, 61, 64, 66, 66, 77, 79, 82, 85, 88, 91, 94, 99], "size": 34}}, {"idx": 7, "outputs": 172, "inputs": {"a": [-56, 0, 16, 12, 20, 36, 32, -52, -68, -36, -96, -46, -34, 56, 2, 78, 6, 30, -68, -48, 2, 44, -26, -36, -30, -20, -90, -66, 4, 94, 8, 4, -4, -32, -24], "size": 20}}, {"idx": 8, "outputs": 10, "inputs": {"a": [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], "size": 22}}, {"idx": 9, "outputs": 1019, "inputs": {"a": [39, 87, 27, 89, 26, 25, 80, 82, 21, 25, 55, 27, 20, 81, 47, 79, 26, 72, 10, 11, 90, 89], "size": 21}}]
question_info.extension: kts
question_info.test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(a: ArrayList<Int>, size: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(a, size), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(arrayListOf(1, 3, 4, 7, 8, 8, 10, 12, 16, 19, 19, 20, 20, 21, 21, 22, 26, 27, 29, 34, 36, 38, 38, 39, 41, 43, 44, 47, 47, 49, 57, 57, 60, 62, 63, 65, 75, 77, 77, 78, 81, 82, 82, 83, 83, 84, 85, 98, 99), 38, 1265)
      println("TEST-0...${result}")
      
      result = driver(arrayListOf(-40, 14, 2, -70, 86, -90, -50, -54, -2, 90, 30), 10, 90)
      println("TEST-1...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 18, 11)
      println("TEST-2...${result}")
      
      result = driver(arrayListOf(60, 69, 41, 7, 77, 36, 36, 26, 35, 30, 64, 75, 3, 35, 60, 71, 29, 47, 15, 29, 43, 88, 56, 22, 9, 45, 40, 50, 52), 25, 1063)
      println("TEST-3...${result}")
      
      result = driver(arrayListOf(-96, -88, -80, -72, -64, -64, -60, -60, -60, -58, -56, -54, -54, -50, -50, -26, -26, -24, -20, -8, -2, 0, 4, 4, 12, 14, 18, 18, 24, 32, 42, 44, 44, 44, 48, 50, 50, 56, 60, 60, 70, 80, 88, 88, 90, 98), 35, 348)
      println("TEST-4...${result}")
      
      result = driver(arrayListOf(0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0), 22, 13)
      println("TEST-5...${result}")
      
      result = driver(arrayListOf(2, 4, 4, 5, 6, 7, 11, 12, 14, 18, 23, 24, 27, 28, 33, 36, 37, 38, 39, 40, 41, 41, 48, 48, 52, 61, 64, 66, 66, 77, 79, 82, 85, 88, 91, 94, 99), 34, 1306)
      println("TEST-6...${result}")
      
      result = driver(arrayListOf(-56, 0, 16, 12, 20, 36, 32, -52, -68, -36, -96, -46, -34, 56, 2, 78, 6, 30, -68, -48, 2, 44, -26, -36, -30, -20, -90, -66, 4, 94, 8, 4, -4, -32, -24), 20, 172)
      println("TEST-7...${result}")
      
      result = driver(arrayListOf(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), 22, 10)
      println("TEST-8...${result}")
      
      result = driver(arrayListOf(39, 87, 27, 89, 26, 25, 80, 82, 21, 25, 55, 27, 20, 81, 47, 79, 26, 72, 10, 11, 90, 89), 21, 1019)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: largestSumContiguousSubarray2
question_info.entry_cls_name: Solution
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: kotlinc -script __FILENAME__ -no-reflect -nowarn