text: using namespace std;
  
  #include <iostream>
  #include <limits>
  #include <vector>
  
  class MinSizeSubArraySum {
   public:
    static int findMinSubArray(int S, const vector<int>& arr) {
      // TODO: Write your code here
      int len = arr.size() + 10;
      int i = 0;
      int sum = 0;
      for(int j = 0; j < arr.size(); j++){
        sum += arr[j];
        if(sum >= S){
          len = min(len, j - i + 1);
          sum -= arr[i];
          i++;
        }
      }
      if(len == arr.size() + 10) return -1;
      return len;
    }
  };
  
  int main(int argc, char* argv[]) {
    int result = MinSizeSubArraySum::findMinSubArray(7, vector<int>{2, 1, 5, 2, 3, 2});
    cout << "Smallest subarray length: " << result << endl;
    result = MinSizeSubArraySum::findMinSubArray(7, vector<int>{2, 1, 5, 2, 8});
    cout << "Smallest subarray length: " << result << endl;
    result = MinSizeSubArraySum::findMinSubArray(8, vector<int>{3, 4, 1, 1, 6});
    cout << "Smallest subarray length: " << result << endl;
  }
  