title: Integer Positive Value Positive Negative Value Array
signature: class Solution {
  
      public Integer integerPositiveValuePositiveNegativeValueArray(ArrayList<Integer> arr, Integer n) {
source_py: def integer_positive_value_positive_negative_value_array(arr, n):
      hash = dict()
      maximum = 0
      for i in arr:
          if (i < 0):
              if (abs(i) not in hash.keys()):
                  hash[abs(i)] = (- 1)
              else:
                  hash[abs(i)] -= 1
          else:
              hash[i] = (hash.get(i, 0) + 1)
      for i in arr:
          if ((i in hash.keys()) and (hash[i] > 0)):
              return i
      return (- 1)
source_cpp: int integer_positive_value_positive_negative_value_array(vector<int> arr, int n) {
    unordered_map < int, int > hash;
    int maximum = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( arr [ i ] < 0 ) hash [ abs ( arr [ i ] ) ] -= 1;
      else hash [ arr [ i ] ] += 1;
    }
    for ( int i = 0;
    i < n;
    i ++ ) if ( hash [ arr [ i ] ] != 0 ) return arr [ i ];
    return - 1;
  }
question_info.extension: java
question_info.entry_fn_name: integerPositiveValuePositiveNegativeValueArray
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 1, "inputs": {"arr": [1, 7, 10, 14, 15, 24, 27, 32, 33, 38, 39, 40, 42, 42, 47, 58, 75, 76, 78, 79, 83, 85, 89, 96], "n": 18}}, {"idx": 1, "outputs": 14, "inputs": {"arr": [-36, 14, -76, -70, 52, 18, 64], "n": 5}}, {"idx": 2, "outputs": 0, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 17}}, {"idx": 3, "outputs": 35, "inputs": {"arr": [35, 50, 36, 50, 82, 54, 10, 45, 13, 22, 1, 41, 13, 11, 4, 43, 50, 27, 94, 57], "n": 15}}, {"idx": 4, "outputs": 4, "inputs": {"arr": [-88, -86, -84, -80, -80, -74, -72, -48, -46, -46, -44, -34, -32, -24, -22, -14, 4, 4, 8, 8, 10, 12, 20, 20, 24, 24, 24, 28, 32, 34, 36, 44, 46, 54, 54, 60, 62, 62, 62, 70, 70, 80, 88, 88, 90], "n": 27}}, {"idx": 5, "outputs": 0, "inputs": {"arr": [0, 0], "n": 1}}, {"idx": 6, "outputs": 1, "inputs": {"arr": [1, 1, 3, 6, 6, 8, 12, 13, 17, 27, 28, 31, 40, 40, 42, 43, 53, 55, 58, 60, 60, 61, 65, 66, 72, 72, 75, 80, 84, 89, 96, 97, 99], "n": 31}}, {"idx": 7, "outputs": 52, "inputs": {"arr": [52, -38, -82, 30, -66, 42, 54, -96, -46, -30, 18, -50, 96, 90, 4, 74, -22, 8, 34, 74, -46, 8, -32, 88, -96, 26, -80, 50, 92, -80, 44, 36], "n": 24}}, {"idx": 8, "outputs": 0, "inputs": {"arr": [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], "n": 16}}, {"idx": 9, "outputs": 38, "inputs": {"arr": [38, 20, 54, 51, 11, 61, 90, 28, 23, 55, 65, 87, 99, 70, 74, 3, 68, 23, 74, 53, 80, 7, 57, 24, 66, 8, 15, 63, 18, 67, 96, 31, 63, 50], "n": 30}}]
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(1, 7, 10, 14, 15, 24, 27, 32, 33, 38, 39, 40, 42, 42, 47, 58, 75, 76, 78, 79, 83, 85, 89, 96)), 18, 1);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-36, 14, -76, -70, 52, 18, 64)), 5, 14);
          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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 17, 0);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(35, 50, 36, 50, 82, 54, 10, 45, 13, 22, 1, 41, 13, 11, 4, 43, 50, 27, 94, 57)), 15, 35);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-88, -86, -84, -80, -80, -74, -72, -48, -46, -46, -44, -34, -32, -24, -22, -14, 4, 4, 8, 8, 10, 12, 20, 20, 24, 24, 24, 28, 32, 34, 36, 44, 46, 54, 54, 60, 62, 62, 62, 70, 70, 80, 88, 88, 90)), 27, 4);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0)), 1, 0);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 1, 3, 6, 6, 8, 12, 13, 17, 27, 28, 31, 40, 40, 42, 43, 53, 55, 58, 60, 60, 61, 65, 66, 72, 72, 75, 80, 84, 89, 96, 97, 99)), 31, 1);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(52, -38, -82, 30, -66, 42, 54, -96, -46, -30, 18, -50, 96, 90, 4, 74, -22, 8, 34, 74, -46, 8, -32, 88, -96, 26, -80, 50, 92, -80, 44, 36)), 24, 52);
          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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 16, 0);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(38, 20, 54, 51, 11, 61, 90, 28, 23, 55, 65, 87, 99, 70, 74, 3, 68, 23, 74, 53, 80, 7, 57, 24, 66, 8, 15, 63, 18, 67, 96, 31, 63, 50)), 30, 38);
          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__