# Task
 Given array of integers, for each position i, search among the previous positions for the last (from the left) position that contains a smaller value. Store this value at position i in the answer. If no such value can be found, store `-1` instead.

# Example

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

# Input/Output


 - `[input]` integer array `arr`

   Non-empty array of positive integers.

   Constraints: `3 ≤ arr.length ≤ 1000, 1 ≤ arr[i] ≤ 1000.`


 - `[output]` an integer array

   Array containing answer values computed as described above.

Difficulty: EASY
Starter code: def array_previous_less(arr):
	

Solutions:
def array_previous_less(arr):
	return [next((y for y in arr[:i][::-1] if y < x), -1) for (i, x) in enumerate(arr)]


def array_previous_less(arr):
	out = []
	for (i, n) in enumerate(arr):
		x = -1
		for m in arr[:i][::-1]:
			if m < n:
				x = m
				break
		out.append(x)
	return out


def array_previous_less(arr):
	new = [-1]
	for i in range(1, len(arr)):
		curr = arr[i]
		while i and arr[i - 1] >= curr:
			i -= 1
		if i:
			new.append(arr[i - 1])
		else:
			new.append(-1)
	return new


def array_previous_less(a):
	r = []
	for (i, x) in enumerate(a):
		for j in range(i - 1, -1, -1):
			if a[j] < x:
				r.append(a[j])
				break
		else:
			r.append(-1)
	return r


def array_previous_less(arr):
	return [next((arr[i - j] for j in range(1, i + 1) if arr[i - j] < v), -1) for (i, v) in enumerate(arr)]


def array_previous_less(arr):
	r = []
	for (i, v) in enumerate(arr):
		x = -1
		for w in arr[:i]:
			if w < v:
				x = w
		r.append(x)
	return r


import numpy as np

def array_previous_less(arr):
	arr = arr[::-1]
	output = np.full(len(arr), -1)
	for i in range(len(arr)):
		for j in arr[i + 1:]:
			if j < arr[i]:
				output[i] = j
				break
	return output.tolist()[::-1]


def array_previous_less(arr):
	return [next((v1 for v1 in arr[:i][::-1] if v1 < v), -1) for (i, v) in enumerate(arr)]


def array_previous_less(arr):
	output = []
	k = 0
	for i in range(0, len(arr)):
		for j in range(i, -1, -1):
			if arr[j] < arr[i]:
				output.append(arr[j])
				k = 1
				break
		if k == 0:
			output.append(-1)
		elif k == 1:
			k = 0
	return output