title: Maximum Area Rectangle Picking Four Sides Array 1
signature: function maximum_area_rectangle_picking_four_sides_array_1(arr, n)
source_py: def maximum_area_rectangle_picking_four_sides_array_1(arr, n):
      s = []
      first = 0
      second = 0
      for i in range(n):
          if (arr[i] not in s):
              s.append(arr[i])
              continue
          if (arr[i] > first):
              second = first
              first = arr[i]
          elif (arr[i] > second):
              second = arr[i]
      return (first * second)
source_cpp: int maximum_area_rectangle_picking_four_sides_array_1(vector<int> arr, int n) {
    unordered_set < int > s;
    int first = 0, second = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( s . find ( arr [ i ] ) == s . end ( ) ) {
        s . insert ( arr [ i ] );
        continue;
      }
      if ( arr [ i ] > first ) {
        second = first;
        first = arr [ i ];
      }
      else if ( arr [ i ] > second ) second = arr [ i ];
    }
    return ( first * second );
  }
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(arr, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver({4, 6, 7, 8, 12, 13, 14, 15, 18, 18, 19, 19, 26, 26, 32, 32, 33, 34, 34, 36, 41, 43, 47, 47, 51, 51, 52, 53, 55, 56, 57, 60, 61, 71, 74, 75, 76, 77, 79, 87, 87, 87, 90, 95, 98, 99}, 37, 2397)
      print(string.format("TEST-0...%s",result))
  
      result = driver({-64, -72, 6, -62, 54, 14, 28, 60, -96, 14, -32, -2, 80, 8, -56, 68, 86, 64, 86, -12, 82}, 12, 0)
      print(string.format("TEST-1...%s",result))
  
      result = driver({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}, 27, 1)
      print(string.format("TEST-2...%s",result))
  
      result = driver({99, 7, 14, 50, 94, 24, 79, 13, 19, 29, 22, 2, 77, 36, 38, 18, 51, 15, 99, 52, 17, 77, 22, 54}, 15, 0)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-96, -92, -86, -84, -84, -80, -70, -70, -68, -64, -64, -48, -46, -24, -22, -20, -8, -8, 0, 0, 4, 8, 8, 22, 28, 36, 46, 50, 52, 54, 60, 62, 66, 70, 80, 84, 86, 94, 96, 96}, 25, 0)
      print(string.format("TEST-4...%s",result))
  
      result = driver({1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1}, 12, 1)
      print(string.format("TEST-5...%s",result))
  
      result = driver({98}, 0, 0)
      print(string.format("TEST-6...%s",result))
  
      result = driver({-88, -24, 8, 20, -46, 60, 24, 26, 98, 82, -30, 16, 22, -28, 84, 12, 34, 14, -18, -38, -94, -24, 6, 4, -52, -48, 84}, 21, 0)
      print(string.format("TEST-7...%s",result))
  
      result = driver({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}, 21, 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver({6, 30, 47, 97, 20, 16, 68, 34, 1, 77, 48, 8, 22, 68}, 8, 0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 2397, "inputs": {"arr": [4, 6, 7, 8, 12, 13, 14, 15, 18, 18, 19, 19, 26, 26, 32, 32, 33, 34, 34, 36, 41, 43, 47, 47, 51, 51, 52, 53, 55, 56, 57, 60, 61, 71, 74, 75, 76, 77, 79, 87, 87, 87, 90, 95, 98, 99], "n": 37}}, {"idx": 1, "outputs": 0, "inputs": {"arr": [-64, -72, 6, -62, 54, 14, 28, 60, -96, 14, -32, -2, 80, 8, -56, 68, 86, 64, 86, -12, 82], "n": 12}}, {"idx": 2, "outputs": 1, "inputs": {"arr": [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], "n": 27}}, {"idx": 3, "outputs": 0, "inputs": {"arr": [99, 7, 14, 50, 94, 24, 79, 13, 19, 29, 22, 2, 77, 36, 38, 18, 51, 15, 99, 52, 17, 77, 22, 54], "n": 15}}, {"idx": 4, "outputs": 0, "inputs": {"arr": [-96, -92, -86, -84, -84, -80, -70, -70, -68, -64, -64, -48, -46, -24, -22, -20, -8, -8, 0, 0, 4, 8, 8, 22, 28, 36, 46, 50, 52, 54, 60, 62, 66, 70, 80, 84, 86, 94, 96, 96], "n": 25}}, {"idx": 5, "outputs": 1, "inputs": {"arr": [1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1], "n": 12}}, {"idx": 6, "outputs": 0, "inputs": {"arr": [98], "n": 0}}, {"idx": 7, "outputs": 0, "inputs": {"arr": [-88, -24, 8, 20, -46, 60, 24, 26, 98, 82, -30, 16, 22, -28, 84, 12, 34, 14, -18, -38, -94, -24, 6, 4, -52, -48, 84], "n": 21}}, {"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, 1, 1, 1, 1], "n": 21}}, {"idx": 9, "outputs": 0, "inputs": {"arr": [6, 30, 47, 97, 20, 16, 68, 34, 1, 77, 48, 8, 22, 68], "n": 8}}]
question_info.extension: lua
question_info.entry_fn_name: maximum_area_rectangle_picking_four_sides_array_1
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__