# Task
Given an integer array `arr`. Your task is to remove one element, maximize the product of elements. 

The result is the element which should be removed. If more than one valid results exist, return the smallest one.


# Input/Output


`[input]` integer array `arr`

non-empty unsorted integer array. It contains positive integer, negative integer or zero.

`3 ≤ arr.length ≤ 15`

`-10 ≤ arr[i] ≤ 10`

`[output]` an integer

The element that should be removed.

# Example

For `arr = [1, 2, 3]`, the output should be `1`.

For `arr = [-1, 2, -3]`, the output should be `2`.

For `arr = [-1, -2, -3]`, the output should be `-1`.

For `arr = [-1, -2, -3, -4]`, the output should be `-4`.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def maximum_product(arr):
	

Solutions:
def maximum_product(arr):
	if arr.count(0) > 1:
		return min(arr)
	neg = [n for n in arr if n < 0]
	pos = [n for n in arr if n >= 0]
	if len(neg) % 2:
		return min(neg) if 0 in arr else max(neg)
	else:
		return min(pos) if pos else min(neg)


from operator import mul
from functools import reduce

def maximum_product(arr):
	prod_dct = {x: reduce(mul, arr[:i] + arr[i + 1:], 1) for (i, x) in enumerate(arr)}
	return max(arr, key=lambda x: (prod_dct[x], -x))


from functools import reduce
from operator import mul

def maximum_product(arr):
	l = [(reduce(mul, arr[:i] + arr[i + 1:]), j) for (i, j) in enumerate(arr)]
	return max(l, key=lambda x: (x[0], -x[1]))[1]


import numpy as np

def maximum_product(arr):
	return -max(((np.multiply.reduce(arr[:c] + arr[c + 1:]), -a) for (c, a) in enumerate(arr)))[1]


from functools import reduce
from operator import mul

def maximum_product(arr):
	prods = {}
	for e in sorted(set(arr))[::-1]:
		a = arr[:]
		a.remove(e)
		prods[reduce(mul, a)] = e
	return prods[max(prods)]


from functools import reduce
from operator import mul

def maximum_product(arr):
	omit_prod = lambda i: reduce(mul, arr[:i] + arr[i + 1:])
	return sorted([(omit_prod(i), -n, n) for (i, n) in enumerate(arr)], reverse=True)[0][2]


def maximum_product(arr):
	pos = [x for x in arr if x > 0]
	neg = [x for x in arr if x < 0]
	if 0 in arr:
		return min(neg) if len(neg) % 2 or (arr.count(0) - 1 and len(neg)) else 0
	if len(neg) % 2:
		return max(neg)
	return min(pos) if len(pos) else min(neg)


def maximum_product(arr):
	a = [n for n in arr if n < 0]
	b = [n for n in arr if n > 0]
	if not a:
		return min(arr)
	if len(a) % 2:
		if 0 in arr:
			return min(a)
		return max(a)
	if not len(a) % 2:
		if arr.count(0) == 1:
			return 0
		if arr.count(0) > 1:
			return min(arr)
		if b:
			return min(b)
	if b:
		return max(b)
	return min(arr)