title: Find Smallest Value Represented Sum Subset Given Array
signature: class Solution {
  
      public Integer findSmallestValueRepresentedSumSubsetGivenArray(ArrayList<Integer> arr, Integer n) {
source_py: def find_smallest_value_represented_sum_subset_given_array(arr, n):
      res = 1
      for i in range(0, n):
          if (arr[i] <= res):
              res = (res + arr[i])
          else:
              break
      return res
source_cpp: int find_smallest_value_represented_sum_subset_given_array(vector<int> arr, int n) {
    int res = 1;
    for ( int i = 0;
    i < n && arr [ i ] <= res;
    i ++ ) res = res + arr [ i ];
    return res;
  }
question_info.extension: java
question_info.entry_fn_name: findSmallestValueRepresentedSumSubsetGivenArray
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 1, "inputs": {"arr": [16, 23, 24, 41, 48, 58, 72, 75], "n": 4}}, {"idx": 1, "outputs": -95, "inputs": {"arr": [-14, -82, 12, -14, -38, 12, 40, 12, -74, 42, -36, 64], "n": 8}}, {"idx": 2, "outputs": 4, "inputs": {"arr": [0, 0, 1, 1, 1, 1], "n": 5}}, {"idx": 3, "outputs": 1, "inputs": {"arr": [17, 89, 44], "n": 2}}, {"idx": 4, "outputs": -93, "inputs": {"arr": [-94, -92, -84, -82, -72, -58, -56, -40, -34, -34, -24, -22, -8, -8, 12, 14, 16, 16, 22, 22, 34, 46, 54, 58, 68, 72, 74, 78, 88, 96], "n": 25}}, {"idx": 5, "outputs": 2, "inputs": {"arr": [0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0], "n": 8}}, {"idx": 6, "outputs": 1, "inputs": {"arr": [2, 12, 13, 13, 13, 16, 28, 32, 34, 41, 41, 47, 49, 49, 50, 52, 58, 61, 63, 65, 67, 68, 68, 74, 80, 80, 84, 84, 89, 93, 94, 98, 99, 99], "n": 23}}, {"idx": 7, "outputs": 1, "inputs": {"arr": [-54], "n": 0}}, {"idx": 8, "outputs": 12, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 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], "n": 33}}, {"idx": 9, "outputs": 1, "inputs": {"arr": [42, 50, 76, 45, 6, 63, 46, 73, 65, 70, 87, 5, 41, 63, 96, 75, 38, 76, 27, 7, 71, 9, 65, 44, 76, 37, 94, 52, 55, 3, 38, 68, 45, 15, 35, 90, 36, 46, 13, 92, 32, 22, 49, 35, 83], "n": 35}}]
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> arr, Integer n, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(arr, n,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(16, 23, 24, 41, 48, 58, 72, 75)), 4, 1);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-14, -82, 12, -14, -38, 12, 40, 12, -74, 42, -36, 64)), 8, -95);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 1, 1, 1, 1)), 5, 4);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(17, 89, 44)), 2, 1);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-94, -92, -84, -82, -72, -58, -56, -40, -34, -34, -24, -22, -8, -8, 12, 14, 16, 16, 22, 22, 34, 46, 54, 58, 68, 72, 74, 78, 88, 96)), 25, -93);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0)), 8, 2);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(2, 12, 13, 13, 13, 16, 28, 32, 34, 41, 41, 47, 49, 49, 50, 52, 58, 61, 63, 65, 67, 68, 68, 74, 80, 80, 84, 84, 89, 93, 94, 98, 99, 99)), 23, 1);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-54)), 0, 1);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 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)), 33, 12);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(42, 50, 76, 45, 6, 63, 46, 73, 65, 70, 87, 5, 41, 63, 96, 75, 38, 76, 27, 7, 71, 9, 65, 44, 76, 37, 94, 52, 55, 3, 38, 68, 45, 15, 35, 90, 36, 46, 13, 92, 32, 22, 49, 35, 83)), 35, 1);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> arr, Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(arr, n),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer 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__