Now, we'll try to solve a famous stack problem. 
You are given an array A of size N. You need to first push the elements of the array into a stack and then print minimum in the stack at each pop until stack becomes empty.
Example 1:
Input:
N = 5
A = {1 2 3 4 5}
Output: 
1 1 1 1 1
Explanation: 
After pushing elements to the stack, 
the stack will be "top -> 5, 4, 3, 2, 1". 
Now, start popping elements from the stack
popping 5: min in the stack is 1.popped 5
popping 4: min in the stack is 1. popped 4
popping 3: min in the stack is 1. popped 3
popping 2: min in the stack is 1. popped 2
popping 1: min in the stack is 1. popped 1
Example 2:
Input: 
N = 7
A = {1 6 43 1 2 0 5}
Output: 
0 0 1 1 1 1 1
Explanation: 
After pushing the elements to the stack, 
the stack will be 5->0->2->1->43->6->1. 
Now, poping the elements from the stack:
popping 5: min in the stack is 0. popped 5
popping 0: min in the stack is 0. popped 0
popping 2: min in the stack is 1. popped 2
popping 1: min in the stack is 1. popped 1
popping 43: min in the stack is 1. 
            popped 43
popping 6: min in the stack is 1. popped 6
popping 1: min in the stack is 1. popped 1.
 
Your Task:
Since this is a function problem, you don't need to take any input. Just complete the provided functions _push() and _getMinAtPop(). The _push() function takes an array as parameter, you need to push all elements of this array onto a stack and return the stack. The _getMinAtPop() accepts a stack as a parameter which is returned by _push() function and prints minimum in the stack at each pop separated by spaces.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).
Constraints:
0 <= A_{i} <= 10^{7}

Difficulty: EASY
Tags: Data structures
Skill types: Data structures
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).

Starter code:
#User function Template for python3



#Function to push all the elements into the stack.

def _push(a,n):



    # code here





#Function to print minimum value in stack each time while popping.    

def _getMinAtPop(stack):

    

    # code here

Solutions:
def _push(a, n):
	stack = []
	for i in a:
		stack.append(i)
	return stack

def _getMinAtPop(stack):
	for i in range(len(stack)):
		print(min(stack), end=' ')
		stack.pop()


def _push(a, n):
	stack = []
	for i in a:
		stack.append(i)
	return stack

def _getMinAtPop(stack):
	while len(stack) != 0:
		mini = stack[-1]
		for i in stack:
			if i < mini:
				mini = i
		stack.pop()
		print(mini, end=' ')


def _push(a, n):
	stack = []
	mini = float('inf')
	for ele in range(n):
		mini = min(mini, a[ele])
		stack.append(mini)
	return stack

def _getMinAtPop(stack):
	while stack:
		print(stack[-1], end=' ')
		stack.pop()


def _push(a, n):
	stack = []
	for element in a:
		stack.append(element)
	return stack

def _getMinAtPop(stack):
	while len(stack) != 0:
		minelement = min(stack)
		stack.pop()
		print(minelement, end=' ')


def _push(a, n):
	return a

def _getMinAtPop(stack):
	min_st = []
	st = []
	for i in range(n):
		if not st:
			st.append(a[i])
			min_st.append(a[i])
		else:
			st.append(a[i])
			if min_st[-1] >= a[i]:
				min_st.append(a[i])
	while st:
		x = st.pop()
		print(min_st[-1], end=' ')
		if x <= min_st[-1]:
			min_st.pop()


def _push(a, n):
	stk = []
	while a:
		stk.append(a.pop(0))
	return stk

def _getMinAtPop(stack):
	while stack:
		print(min(stack), end=' ')
		stack.pop()


def _push(a, n):
	return a

def _getMinAtPop(stack):
	aux_stack = []
	for num in stack:
		if len(aux_stack) == 0:
			aux_stack.append(num)
		elif num < aux_stack[-1]:
			aux_stack.append(num)
	while len(stack) != 0:
		popped = stack.pop()
		if popped > aux_stack[-1]:
			print(aux_stack[-1], end=' ')
		else:
			print(aux_stack[-1], end=' ')
			aux_stack.pop()


def _push(a, n):
	s = []
	for i in a:
		s.append(i)
	return s

def _getMinAtPop(stack):
	while len(stack) != 0:
		if len(stack) != 0:
			print(min(stack), end=' ')
		stack.pop()


def _push(a, n):
	stack = []
	for i in range(n):
		stack.append(a[i])
	return stack

def _getMinAtPop(stack):
	minm_stack = []
	for i in range(len(stack)):
		if not minm_stack or stack[i] <= minm_stack[-1]:
			minm_stack.append(stack[i])
	while stack:
		print(minm_stack[-1], end=' ')
		if minm_stack[-1] == stack.pop():
			minm_stack.pop()


def _push(a, n):
	st = []
	for i in a:
		st.append(i)
	return st

def _getMinAtPop(stack):
	while len(stack) > 0:
		print(min(stack), sep=' ', end=' ')
		stack.pop()


def _push(a, n):
	return a

def _getMinAtPop(stack):
	s = sorted(stack)
	s = s[::-1]
	for i in range(len(stack)):
		print(s[-1], end=' ')
		s.remove(stack[-1])
		stack.pop()


def _push(a, n):
	stack = []
	minVal = a[0]
	stack.append(a[0])
	for i in range(1, n):
		if minVal > a[i]:
			minVal = a[i]
		stack.append(minVal)
	return stack

def _getMinAtPop(stack):
	for i in range(len(stack)):
		print(stack[len(stack) - 1], end=' ')
		del stack[len(stack) - 1]


minstack = []
stack = []

def _push(a, n):
	global minstack
	global stack
	min_so_far = a[0]
	stack.append(a[0])
	minstack.append(a[0])
	for i in range(1, n):
		stack.append(a[i])
		if a[i] <= min_so_far:
			min_so_far = a[i]
			minstack.append(a[i])
	return stack

def _getMinAtPop(stack):
	global minstack
	while len(stack) != 0:
		x = stack.pop()
		m = minstack.pop()
		if x != m:
			minstack.append(m)
			print(m, end=' ')
		else:
			print(m, end=' ')


def _push(a, n):
	arr = []
	for i in a:
		arr.append(i)
	return arr

def _getMinAtPop(stack):
	mini = min(stack)
	while len(stack) != 0:
		if stack[-1] == mini and len(stack) > 1:
			stack.pop()
			print(mini, end=' ')
			mini = min(stack)
		else:
			stack.pop()
			print(mini, end=' ')


def _push(a, n):
	return a

def _getMinAtPop(stack):
	x = []
	while stack:
		x = min(stack)
		stack.pop()
		print(x, end=' ')


def _push(a, n):
	stack = []
	for element in a:
		stack.append(element)
	return stack

def _getMinAtPop(stack):
	while len(stack) != 0:
		minElement = stack[-1]
		for element in stack:
			if element < minElement:
				minElement = element
		stack.pop()
		print(minElement, end=' ')


class Stack:

	def __init__(self, maxsize):
		self.maxsize = maxsize
		self.top = -1
		self.arr = []

	def empty(self):
		return self.top == -1

	def full(self):
		return self.top == self.maxsize

	def push(self, data):
		if self.full():
			return 'Stack is full'
		self.top += 1
		self.arr.append(data)

	def peek(self):
		if self.empty():
			return 'Stack is empty'
		return self.arr[self.top]

	def pop(self):
		if self.empty():
			return 'Stack is empty'
		top_ele = self.arr.pop()
		self.top -= 1
		return top_ele

	def minimum(self):
		return min(self.arr)

def _push(a, n):
	stack = Stack(maxsize=n)
	for ele in a:
		stack.push(ele)
	return stack

def _getMinAtPop(stack):
	while not stack.empty():
		print(stack.minimum(), end=' ')
		stack.pop()


def _push(a, n):
	s = []
	s.append(a[0])
	for i in range(1, n):
		s.append(min(s[-1], a[i]))
	return s

def _getMinAtPop(stack):
	while not stack == []:
		print(stack[-1], end=' ')
		stack.pop()


def _push(a, n):
	st = []
	min_el = float('inf')
	for i in range(n):
		min_el = min(min_el, a[i])
		st.append(min_el)
	return st

def _getMinAtPop(stack):
	while len(stack) > 0:
		print(stack.pop(), end=' ')


def _push(arr, n):
	A = []
	for i in range(n):
		A.append(arr[i])
	return A

def _getMinAtPop(stack):
	for i in range(len(stack)):
		print(min(stack), end=' ')
		stack.pop()


def _push(a, n):
	s = []
	for x in range(n):
		s.append(a[x])
	return s

def _getMinAtPop(stack):
	for x in range(len(stack)):
		print(min(stack), end=' ')
		stack.pop()


def _push(a, n):
	a.append(n)
	return a

def _getMinAtPop(stack):
	while stack:
		stack.pop()
		if stack:
			print(min(stack), end=' ')


def _push(a, n):
	stack = []
	for i in range(n):
		stack.append(a[i])
	return stack

def _getMinAtPop(stack):
	minm = [float('inf')]
	for i in range(n):
		if minm[-1] >= a[i]:
			minm.append(a[i])
	for j in range(n):
		print(minm[-1], end=' ')
		if stack.pop() == minm[-1]:
			minm.pop()


def _push(a, n):
	stack = []
	for i in a:
		stack.append(i)
	return stack

def _getMinAtPop(stack):
	min = 1000000000
	min_arr = []
	for i in stack:
		if i < min:
			min = i
		min_arr.append(min)
	min_arr = min_arr[::-1]
	for i in min_arr:
		print(i, end=' ')


def _push(a, n):
	return a

def _getMinAtPop(stack):
	while len(stack) != 0:
		print(min(stack), end=' ')
		a = stack.pop()


def _push(a, n):
	stack = []
	for i in range(n):
		if len(stack) == 0:
			stack.append(a[i])
		elif a[i] < stack[-1]:
			stack.append(a[i])
		else:
			stack.append(stack[-1])
	return stack

def _getMinAtPop(stack):
	while stack:
		print(stack.pop(), end=' ')


def _push(a, n):
	s = []
	for i in range(n):
		s.append(a[i])
	s.reverse()
	return s

def _getMinAtPop(s):
	i = 0
	k = s
	m = min(s)
	m1 = max(s)
	n = len(s)
	while i < n:
		if s[i] != m:
			print(m, end=' ')
		else:
			print(m, end=' ')
			s[i] = m1
			m = min(s[i:])
		i += 1


from collections import deque

def _push(a, n):
	st = deque()
	st.append(a[0])
	for i in range(1, n):
		currval = a[i]
		minval = min(st[-1], currval)
		st.append(minval)
	return st

def _getMinAtPop(stack):
	while len(stack) != 0:
		print(stack.pop(), end=' ')


def _push(a, n):
	stack = []
	for ele in a:
		if len(stack) == 0:
			stack.append([ele, ele])
		else:
			stack.append([ele, min(stack[-1][1], ele)])
	return stack

def _getMinAtPop(stack):
	s = []
	for ele in stack:
		s.append(ele[1])
	for ele in s[::-1]:
		print(ele, end=' ')


def _push(a, n):
	return a

def _getMinAtPop(stack):
	min1 = stack[0]
	minimum = []
	for i in range(0, len(stack)):
		if min1 > stack[i]:
			min1 = stack[i]
		minimum.append(min1)
	minimum.reverse()
	for i in range(0, len(minimum)):
		print(minimum[i], end=' ')


from collections import deque

def _push(a, n):
	s = deque()
	s.append(a[0])
	for i in range(1, n):
		currentVal = a[i]
		presVal = s[-1]
		minVal = min(currentVal, presVal)
		s.append(minVal)
	return s

def _getMinAtPop(stack):
	while len(stack) != 0:
		print(stack.pop(), end=' ')


def _push(a, n):
	stack = [x for x in a[::-1]]
	_getMinAtPop(stack)
	return stack

def _getMinAtPop(stack):
	minimum = 9999999999999
	min_list = []
	while stack:
		a = stack.pop()
		minimum = min(minimum, a)
		min_list.append(min(minimum, a))
	print(*min_list[::-1], end=' ')


import collections

def _push(a, n):
	stack = [a[0]]
	for item in a[1:]:
		stack.append(min(stack[-1], item))
	return stack

def _getMinAtPop(stack):
	while stack:
		print(stack.pop(), end=' ')


def _push(a, n):
	minStack = []
	for i in range(n):
		currentElement = a[i]
		if len(minStack) == 0:
			minStack.append(currentElement)
			continue
		minSoFar = minStack[-1]
		if currentElement < minSoFar:
			minStack.append(currentElement)
		else:
			minStack.append(minSoFar)
	return minStack

def _getMinAtPop(stack):
	stack.reverse()
	for i in range(len(stack)):
		print(stack[i], end=' ')


def _push(a, n):
	stack = []
	min = float('inf')
	for i in a:
		if min == float('inf'):
			min = i
		elif i < min:
			min = i
		stack.append(min)
	return stack

def _getMinAtPop(stack):
	while stack:
		print(stack.pop(), end=' ')


def _push(lst, n):
	stack = []
	curr_min = lst[0]
	for i in lst:
		stack.append(i)
		if i < curr_min:
			curr_min = i
		stack.append(curr_min)
	return stack

def _getMinAtPop(s):
	while s:
		print(s.pop(), end=' ')
		s.pop()


def _push(a, n):
	stack = []
	for i in a:
		stack.append(i)
	return stack

def _getMinAtPop(stack):
	while stack:
		print(min(stack), end=' ')
		stack.pop()


def _push(a, n):
	stack = a[:]
	return stack

def _getMinAtPop(stack):
	lis = []
	while stack:
		s = min(stack)
		stack.pop()
		print(s, end=' ')


def _push(a, n):
	stack = []
	for i in a:
		stack.append(i)
	return stack

def _getMinAtPop(stack):
	res = []
	res.append(stack[0])
	for i in range(1, len(stack)):
		if stack[i] < res[-1]:
			res.append(stack[i])
		else:
			res.append(res[-1])
	for i in range(len(stack) - 1, -1, -1):
		print(res[i], end=' ')


from collections import deque

def _push(a, n):
	stack = deque()
	for i in a:
		stack.append(i)
	return stack

def _getMinAtPop(stack):
	reverseStack = deque()
	while len(stack):
		reverseStack.append(stack.pop())
	stack.append(reverseStack.pop())
	while len(reverseStack):
		if stack[-1] < reverseStack[-1]:
			stack.append(stack[-1])
			reverseStack.pop()
		else:
			stack.append(reverseStack.pop())
	while len(stack):
		print(stack.pop(), end=' ')


import collections

def _push(a, n):
	return a

def _getMinAtPop(stack):
	while stack:
		print(min(stack), end=' ')
		stack.pop()


def _push(a, n):
	min_ = float('inf')
	s = []
	for num in a:
		min_ = min(min_, num)
		s.append(min_)
	return s

def _getMinAtPop(stack):
	while stack:
		print(stack.pop(), end=' ')


def _push(a, n):
	l = []
	for i in range(n):
		l.append(a[i])
	return l

def _getMinAtPop(stack):
	c = len(stack)
	i = 0
	l = []
	while i != c - 1:
		a = min(stack)
		stack.pop()
		l.append(a)
		i += 1
	l.append(min(stack))
	stack = []
	stack += l
	for i in stack:
		print(i, end=' ')


from sys import maxsize

def _push(a, n):
	return a

def _getMinAtPop(stack):
	res = []
	m = maxsize
	for i in range(len(stack)):
		m = min(a[i], m)
		res.append(m)
	res.reverse()
	for i in range(len(res)):
		print(res[i], end=' ')


def _push(a, n):
	ans = []
	for i in range(n):
		ans.append(a[i])
	return ans

def _getMinAtPop(stack):
	out = []
	while len(stack) > 0:
		mn = min(stack)
		a = stack.pop()
		if a < mn:
			mn = a
		print(mn, end=' ')


def _push(a, n):
	stack1 = []
	while len(a) != 0:
		mini = min(a)
		a.pop()
		stack1.append(mini)
	return stack1[:]

def _getMinAtPop(stack):
	for i in stack:
		print(i, end=' ')