title: Minimum Length Subarray Sum Greater Given Value
signature: minimum_length_subarray_sum_greater_given_value <- function(arr, n, x) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, x, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n, x), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(6L, 11L, 11L, 14L, 18L, 19L, 21L, 22L, 22L, 23L, 26L, 27L, 28L, 28L, 29L, 30L, 31L, 34L, 39L, 42L, 42L, 44L, 45L, 49L, 49L, 53L, 57L, 61L, 65L, 66L, 67L, 70L, 71L, 73L, 74L, 74L, 78L, 85L, 88L, 94L, 95L, 97L), 37L, 23L, 
          1L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-30L, -22L, -66L, -80L, 18L, -64L, -28L, -46L, 94L, 60L, -64L, 2L, 26L, -94L, 58L, 56L, 56L, 88L, 50L, -78L, -12L, 68L, 54L, -78L, 42L, -30L, 24L, -48L, 84L, 12L, -88L, 0L, 54L, -92L, -4L, 42L, -60L, -72L, -32L), 31L, 29L, 
          1L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 8L, 12L, 
          9L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(86L, 8L, 23L, 40L, 55L, 93L, 11L, 35L, 33L, 37L, 96L, 91L, 35L, 66L, 37L, 57L, 83L, 99L, 96L, 15L, 18L, 93L), 16L, 13L, 
          1L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-92L, -68L, -48L, -48L, -42L, -26L, -22L, -18L, 2L, 4L, 8L, 14L, 20L, 22L, 32L, 46L, 52L, 62L, 70L, 96L, 98L), 17L, 14L, 
          18L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 0L), 11L, 10L, 
          12L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(4L, 4L, 11L, 11L, 13L, 15L, 16L, 18L, 19L, 19L, 19L, 23L, 26L, 27L, 34L, 39L, 39L, 40L, 41L, 46L, 47L, 51L, 52L, 52L, 53L, 57L, 58L, 58L, 60L, 64L, 68L, 70L, 72L, 84L, 84L, 85L, 95L, 98L, 99L), 31L, 35L, 
          1L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(12L, -22L, 2L, -90L, -92L, 84L, -26L, -76L, -72L, 50L, -36L, 30L, 78L, -18L, -94L, -30L, 22L, 28L, 10L, 32L, 34L, -86L, 0L, -4L, 40L, 0L, 80L, 50L, 66L, -48L, -40L, -94L, 64L, 58L, -14L, 0L, -32L, -58L, -22L, -94L, -68L, -36L, -94L, -48L, 40L, 78L, -74L), 42L, 26L, 
          43L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 25L, 21L, 
          26L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(1L, 33L, 20L, 32L, 76L, 27L, 8L, 95L, 78L, 72L, 25L, 56L), 9L, 10L, 
          1L
      )))
  
  }
  
  main()
source_py: def minimum_length_subarray_sum_greater_given_value(arr, n, x):
      curr_sum = 0
      min_len = (n + 1)
      start = 0
      end = 0
      while (end < n):
          while ((curr_sum <= x) and (end < n)):
              curr_sum += arr[end]
              end += 1
          while ((curr_sum > x) and (start < n)):
              if ((end - start) < min_len):
                  min_len = (end - start)
              curr_sum -= arr[start]
              start += 1
      return min_len
source_cpp: int minimum_length_subarray_sum_greater_given_value(vector<int> arr, int n, int x) {
    int curr_sum = 0, min_len = n + 1;
    int start = 0, end = 0;
    while ( end < n ) {
      while ( curr_sum <= x && end < n ) curr_sum += arr [ end ++ ];
      while ( curr_sum > x && start < n ) {
        if ( end - start < min_len ) min_len = end - start;
        curr_sum -= arr [ start ++ ];
      }
    }
    return min_len;
  }