title: Search Insert And Delete In An Unsorted Array
signature: function search_insert_and_delete_in_an_unsorted_array(arr, n, key)
source_py: def search_insert_and_delete_in_an_unsorted_array(arr, n, key):
      for i in range(n):
          if (arr[i] == key):
              return i
      return (- 1)
source_cpp: int search_insert_and_delete_in_an_unsorted_array(vector<int> arr, int n, int key) {
    int i;
    for ( i = 0;
    i < n;
    i ++ ) if ( arr [ i ] == key ) return i;
    return - 1;
  }
question_info.entry_fn_name: search_insert_and_delete_in_an_unsorted_array
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
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, key, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, n, key) 
      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, 8, 11, 23, 55, 57, 73, 74, 77, 79, 93}, 8, 11, 2)
      print(string.format("TEST-0...%s",result))
  
      result = driver({-88, 12, -62, -66, -24, 18, 12, 22, 94, 30, -50, -42, -94, 18, 76, -6, -48, -68, 48, 36, -78, 52, -82, 76, 2, -44, -10, 88}, 27, 12, 1)
      print(string.format("TEST-1...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1}, 11, 0, 0)
      print(string.format("TEST-2...%s",result))
  
      result = driver({33, 9, 93, 70, 81, 70, 56, 66, 72, 81, 74, 32, 71, 72, 3, 81, 70, 22, 82, 2, 75, 18, 90, 29, 48}, 24, 72, 8)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-98, -70, -62, -60, -60, -54, -48, -48, -46, -44, -34, -26, -18, -6, 4, 18, 28, 32, 34, 40, 50, 54, 56, 62, 64, 64, 98}, 18, 23, -1)
      print(string.format("TEST-4...%s",result))
  
      result = driver({1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1}, 17, 16, -1)
      print(string.format("TEST-5...%s",result))
  
      result = driver({4, 6, 7, 10, 10, 12, 13, 18, 23, 29, 29, 34, 46, 54, 60, 61, 63, 67, 69, 70, 72, 76, 79, 79, 81, 82, 88, 90, 99}, 15, 28, -1)
      print(string.format("TEST-6...%s",result))
  
      result = driver({94, 34, -60, -74, 86, 80, 68, -48, 78, -62, -98, -44, -44, 92, -94, -86, -36, 12, 84, -90, 52, 42, -42, -66, 88, 76, 66}, 21, 16, -1)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 0, 0, 1}, 2, 3, -1)
      print(string.format("TEST-8...%s",result))
  
      result = driver({76, 59, 38, 83, 38, 93, 27, 11, 17, 80, 26, 28, 35, 53, 88, 10, 9, 75}, 12, 13, -1)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 2, "inputs": {"arr": [4, 8, 11, 23, 55, 57, 73, 74, 77, 79, 93], "n": 8, "key": 11}}, {"idx": 1, "outputs": 1, "inputs": {"arr": [-88, 12, -62, -66, -24, 18, 12, 22, 94, 30, -50, -42, -94, 18, 76, -6, -48, -68, 48, 36, -78, 52, -82, 76, 2, -44, -10, 88], "n": 27, "key": 12}}, {"idx": 2, "outputs": 0, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1], "n": 11, "key": 0}}, {"idx": 3, "outputs": 8, "inputs": {"arr": [33, 9, 93, 70, 81, 70, 56, 66, 72, 81, 74, 32, 71, 72, 3, 81, 70, 22, 82, 2, 75, 18, 90, 29, 48], "n": 24, "key": 72}}, {"idx": 4, "outputs": -1, "inputs": {"arr": [-98, -70, -62, -60, -60, -54, -48, -48, -46, -44, -34, -26, -18, -6, 4, 18, 28, 32, 34, 40, 50, 54, 56, 62, 64, 64, 98], "n": 18, "key": 23}}, {"idx": 5, "outputs": -1, "inputs": {"arr": [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1], "n": 17, "key": 16}}, {"idx": 6, "outputs": -1, "inputs": {"arr": [4, 6, 7, 10, 10, 12, 13, 18, 23, 29, 29, 34, 46, 54, 60, 61, 63, 67, 69, 70, 72, 76, 79, 79, 81, 82, 88, 90, 99], "n": 15, "key": 28}}, {"idx": 7, "outputs": -1, "inputs": {"arr": [94, 34, -60, -74, 86, 80, 68, -48, 78, -62, -98, -44, -44, 92, -94, -86, -36, 12, 84, -90, 52, 42, -42, -66, 88, 76, 66], "n": 21, "key": 16}}, {"idx": 8, "outputs": -1, "inputs": {"arr": [0, 0, 0, 1], "n": 2, "key": 3}}, {"idx": 9, "outputs": -1, "inputs": {"arr": [76, 59, 38, 83, 38, 93, 27, 11, 17, 80, 26, 28, 35, 53, 88, 10, 9, 75], "n": 12, "key": 13}}]