Given a stack, delete the middle element of the stack without using any additional data structure.
Middle element:- ceil((size_of_stack+1)/2) (1-based indexing) from bottom of the stack.
Note: The output shown by the compiler is the stack from top to bottom.
 
Example 1:
Input: 
Stack = {10, 20, 30, 40, 50}
Output:
ModifiedStack = {10, 20, 40, 50}
Explanation:
If you print the stack the bottom-most element will be 10 and the top-most element will be 50. Middle element will be element at index 3 from bottom, which is 30. Deleting 30, stack will look like {10 20 40 50}.
Example 2:
Input: 
Stack = {10 20 30 40}
Output:
ModifiedStack = {10 30 40}
Explanation:
If you print the stack the bottom-most element will be 10 and the top-most element will be 40. Middle element will be element at index 2 from bottom, which is 20. Deleting 20, stack will look like {10 30 40}.
Your Task:
You don't need to read input or print anything. Complete the function deleteMid() which takes the stack and its size as input parameters and modifies the stack in-place.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Constraints:
2 ≤ size of stack ≤ 10^{5}

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Complete search

Starter code: #User function Template for python3



class Solution:

    

    #Function to delete middle element of a stack.

    def deleteMid(self, s, sizeOfStack):

        # code here

Solutions:
from math import ceil

class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack % 2 == 0:
			index = sizeOfStack // 2
		else:
			index = (sizeOfStack + 1) // 2 - 1

		def recursive(s, i):
			if i == index:
				s.pop()
				return
			val = s.pop()
			recursive(s, i + 1)
			s.append(val)
		recursive(s, 0)
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		s.pop((len(s) - 1) // 2)
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack % 2 == 0:
			x = sizeOfStack // 2 - 1
		else:
			x = sizeOfStack // 2
		s.pop(x)
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack == 0:
			return s
		k = sizeOfStack // 2 + 1

		def solve(s, k):
			if k == 1:
				s.pop()
			else:
				temp = s.pop()
				solve(s, k - 1)
				s.append(temp)
		solve(s, k)


from math import *

class Solution:

	def deleteMid(self, stack, n):

		def sol(stack, n, pos):
			if pos == n // 2:
				stack.pop()
				return stack
			val = stack.pop()
			sol(stack, n, pos + 1)
			stack.append(val)
		return sol(stack, n, 0)


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		temp_st = list()
		for i in range(int(math.ceil(sizeOfStack + 1) / 2)):
			temp_st.append(s.pop(-1))
		if sizeOfStack % 2:
			temp_st.pop(-1)
		else:
			s.pop(-1)
		while len(temp_st):
			s.append(temp_st.pop(-1))
		return s


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):

		def delete_mid(st, size, count):
			if count == math.ceil((size + 1) / 2):
				st.pop()
				return
			num = st.pop()
			count += 1
			delete_mid(st, size, count)
			st.append(num)
		delete_mid(s, sizeOfStack, 1)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack % 2 == 0:
			mid = sizeOfStack // 2 - 1
		else:
			mid = sizeOfStack // 2

		def delete(i, s, sizeOfStack):
			if i == sizeOfStack - 1:
				return
			(s[i], s[i + 1]) = (s[i + 1], s[i])
			delete(i + 1, s, sizeOfStack)
		delete(mid, s, sizeOfStack)
		s.pop()
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack % 2 == 1:
			s.pop(sizeOfStack // 2)
		elif sizeOfStack % 2 == 0:
			s.pop(sizeOfStack // 2 - 1)
		return s


class Solution:

	def deleteMid(self, s, size):
		if size % 2 == 0:
			mid = size // 2 - 1
		else:
			mid = size // 2
		s.pop(mid)
		return s


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		n = len(s)
		k = math.ceil((n + 1) / 2)
		self.solve(s, n, 1, k)
		return s

	def solve(self, st, n, count, k):
		if count == k:
			st.pop()
			return
		num = st[-1]
		st.pop()
		self.solve(st, n, count + 1, k)
		st.append(num)


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		m = []
		me = math.ceil(sizeOfStack / 2)
		me = me - 1
		z = sizeOfStack - me - 1
		for i in range(z):
			m.append(s.pop())
		s.pop()
		for i in range(z):
			s.append(m.pop())
		return s


class Solution:

	def deleteMid(self, s, n):
		m = int((n + 1) / 2) - 1
		s.pop(m)
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack % 2 == 0:
			mid = sizeOfStack // 2
		else:
			mid = (sizeOfStack + 1) // 2
		temp_stack = []
		for i in range(sizeOfStack - mid):
			x = s.pop()
			temp_stack.append(x)
		s.pop()
		for i in range(sizeOfStack - mid):
			x = temp_stack.pop()
			s.append(x)


class Solution:

	def delete(self, n, s, size):
		if size == n:
			s.pop()
			return
		temp = s.pop()
		self.delete(n, s, size - 1)
		s.append(temp)
		return s

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack % 2 == 0:
			n = sizeOfStack // 2
		else:
			n = sizeOfStack // 2 + 1
		size = sizeOfStack
		return self.delete(n, s, size)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		l = []
		if sizeOfStack % 2 == 0:
			sizeOfStack += 1
		for i in range(sizeOfStack):
			if i < sizeOfStack // 2:
				temp = s.pop()
				l.append(temp)
			elif i == sizeOfStack // 2:
				temp = s.pop()
				continue
			elif i > sizeOfStack // 2:
				temp = l.pop()
				s.append(temp)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if len(s) == 0:
			return stack
		k = (sizeOfStack + 1) // 2
		k = sizeOfStack - k + 1
		self.deleteStack(s, k)
		return s

	def deleteStack(self, s, k):
		if k == 1:
			s.pop()
			return
		popped_element = s.pop()
		self.deleteStack(s, k - 1)
		s.append(popped_element)


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		mid = len(s) // 2
		if len(s) % 2 == 0:
			x = mid - 1
			del s[x]
		else:
			del s[mid]
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		a = []
		b = sizeOfStack // 2 if sizeOfStack % 2 == 0 else sizeOfStack // 2 + 1
		i = sizeOfStack
		while i > 0:
			if i != b:
				a.append(s.pop())
			else:
				s.pop()
			i = i - 1
		i = sizeOfStack - 1
		while i > 0:
			s.append(a.pop())
			i = i - 1


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if len(s) == 0:
			return
		elif len(s) == 1:
			return s.pop()
		else:
			mid = (sizeOfStack + 1) // 2
			if len(s) == mid:
				s.pop()
				return
			else:
				n = s.pop()
				self.deleteMid(s, sizeOfStack)
				s.append(n)


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		ind = sizeOfStack // 2
		if sizeOfStack % 2 == 0:
			ind -= 1
		stk = []
		for i in range(sizeOfStack - 1, ind, -1):
			stk.append(s.pop())
		s.pop()
		for i in range(len(stk)):
			s.append(stk.pop())
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack == 2:
			del s[0]
		if sizeOfStack % 2 == 0:
			midele = sizeOfStack // 2 - 1
			count = 0
			for i in range(len(s)):
				count += 1
				if count == midele:
					del s[count]
		else:
			midele = sizeOfStack // 2
			count = 0
			for i in range(len(s)):
				count += 1
				if count == midele:
					del s[count]
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack % 2 == 0:
			temp = int(sizeOfStack // 2) - 1
		else:
			temp = int(sizeOfStack // 2)
		s[:] = s[:temp] + s[temp + 1:]


class Solution:

	def deleteMid(self, s, sizeOfStack):
		mid_ele = sizeOfStack - (sizeOfStack + 1) // 2
		aux_stack = []
		while mid_ele:
			aux_stack.append(s.pop())
			mid_ele -= 1
		s.pop()
		while len(aux_stack) != 0:
			s.append(aux_stack.pop())


class Solution:

	def deleteMid(self, s, sizeOfStack):

		def helper(s, n, i):
			if i == n // 2:
				s.pop()
				return
			no = s.pop()
			helper(s, n, i + 1)
			s.append(no)
		helper(s, sizeOfStack, 0)
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):

		def search(s, k):
			if k == 1:
				s.pop()
				return
			val = s[-1]
			s.pop()
			search(s, k - 1)
			s.append(val)
			return s
		n = len(s)
		k = n // 2 + 1
		search(s, k)
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack % 2 == 0:
			mid = sizeOfStack // 2 - 1
		else:
			mid = sizeOfStack // 2
		del s[mid]
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		k = int(sizeOfStack / 2) + 1

		def sol(s, k):
			if k == 1:
				s.pop()
				return
			m = s.pop()
			sol(s, k - 1)
			s.append(m)
		sol(s, k)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if len(s) % 2 == 0:
			q = int(sizeOfStack // 2) - 1
		else:
			q = int(sizeOfStack // 2)

		def milano(s, q, i):
			if i == q:
				s.pop(i)
				return
			milano(s, q, i + 1)
		milano(s, q, 0)


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		mid = math.ceil((sizeOfStack - 1) / 2)
		if sizeOfStack == 1:
			mid = 0

		def delete(s, mid):
			if mid == 0:
				s.pop()
				return
			top = s.pop()
			delete(s, mid - 1)
			s.append(top)
		delete(s, mid)
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		temp = []
		i = 0
		while i < sizeOfStack // 2:
			temp.append(s.pop())
			i += 1
		s.pop()
		while len(temp) != 0:
			s.append(temp.pop())
		return s


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		count = math.ceil((sizeOfStack + 1) / 2) - 1
		stack = []
		i = 0
		while i < count:
			stack.append(s[len(s) - 1])
			del s[len(s) - 1]
			i += 1
		del s[len(s) - 1]
		while len(stack) > 0:
			s.append(stack[len(stack) - 1])
			del stack[len(stack) - 1]


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		if len(s) % 2 != 0:
			del s[math.ceil((sizeOfStack + 1) / 2) - 1]
		else:
			del s[math.ceil((sizeOfStack + 1) / 2) - 2]


import math

class Solution:

	def deleteMid(self, stack, sizeOfStack):
		size_of_stack = len(stack)
		middle_index = size_of_stack // 2
		temp_stack = []
		for i in range(middle_index):
			temp_stack.append(stack.pop())
		stack.pop()
		while temp_stack:
			stack.append(temp_stack.pop())
		return stack


class Solution:

	def deleteMid(self, s, sizeOfStack):
		li = []
		mid = (sizeOfStack - 1) // 2
		i = sizeOfStack - 1
		while i > mid:
			li.append(s.pop())
			i -= 1
		s.pop()
		while len(li) != 0:
			s.append(li.pop())


class Solution:

	def deleteMid(self, s, sizeOfStack):
		mid = (sizeOfStack - 1) // 2
		index = sizeOfStack - 1
		temp = []
		while index > mid:
			temp.append(s.pop())
			index -= 1
		s.pop()
		while len(temp) != 0:
			s.append(temp.pop())
		return s


from math import ceil

class Solution:

	def deleteMid(self, s, sizeOfStack):
		val = sizeOfStack // 2
		if len(s) % 2 == 0:
			s.pop(val - 1)
		else:
			s.pop(val)


class Solution:

	def recDel(self, s, n, curr):
		if curr == n // 2:
			s.pop()
			return
		x = s.pop()
		curr += 1
		self.recDel(s, n, curr)
		s.append(x)

	def deleteMid(self, s, sizeOfStack):
		self.recDel(s, sizeOfStack, 0)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		index = int((sizeOfStack - 1) / 2)
		i = sizeOfStack - 1
		st = []
		while i > index:
			x = s.pop()
			st.append(x)
			i = i - 1
		x = s.pop()
		while len(st) != 0:
			x = st.pop()
			s.append(x)


class Solution:

	def solve(self, s, sizeOfStack, count):
		if count == sizeOfStack // 2:
			s.pop()
			return
		num = s.pop()
		self.solve(s, sizeOfStack, count + 1)
		s.append(num)

	def deleteMid(self, s, sizeOfStack):
		count = 0
		self.solve(s, sizeOfStack, count)


import math

class Solution:

	def deleteHelper(self, s, count, pos):
		if len(s) == 0:
			return
		if count == pos:
			s.pop()
			return
		top = s.pop()
		self.deleteHelper(s, count + 1, pos)
		s.append(top)

	def deleteMid(self, s, sizeOfStack):
		pos = math.ceil((sizeOfStack + 1) / 2.0)
		self.deleteHelper(s, 1, pos)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		mid = sizeOfStack // 2 if sizeOfStack & 1 else sizeOfStack // 2 - 1
		s.pop(mid)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		mid = len(s) // 2
		if len(s) % 2 == 0:
			s.pop(mid - 1)
			return s
		s.pop(mid)
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		k = []
		for i in range(sizeOfStack // 2):
			k.append(s.pop())
		s.pop()
		while len(k) != 0:
			s.append(k.pop())


class Solution:

	def deleteMid(self, s, sizeOfStack):
		temp_stack = []
		mid = sizeOfStack // 2
		for i in range(mid):
			temp_stack.append(s.pop())
		s.pop()
		while temp_stack:
			s.append(temp_stack.pop())


class Solution:

	def deleteMid(self, s, sizeOfStack):
		count = sizeOfStack - 1
		length = count // 2
		arr = []
		while length < count:
			arr.append(s[count])
			count -= 1
			s.pop()
		s.pop()
		for i in range(len(arr) - 1, -1, -1):
			s.append(arr[i])


class Solution:

	def deleteMid(self, s, sizeOfStack):
		a = sizeOfStack // 2
		if sizeOfStack % 2 != 0:
			b = s.pop(a)
		else:
			c = s.pop(a - 1)


class Solution:

	def deleteMid(self, s, n):
		s.pop(int((n + 1) / 2 - 1))


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		middle = sizeOfStack // 2
		if sizeOfStack % 2 == 0:
			middle -= 1
		s.pop(middle)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		k = sizeOfStack // 2 if sizeOfStack % 2 == 0 else sizeOfStack // 2 + 1

		def func(s, k):
			if len(s) == k:
				s.pop()
				return s
			p = s.pop()
			r = func(s, k)
			s.append(p)
			return s
		return func(s, k)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		mid = (sizeOfStack - 1) // 2
		s.pop(mid)


class Solution:

	def deleteMid(self, s, n):
		val = n // 2
		count = 0

		def help(s, n, val, count):
			if val == count:
				s.pop()
				return
			else:
				temp = s.pop()
				help(s, n, val, count + 1)
				s.append(temp)
			return s
		return help(s, n, val, count)


def delete(s, sizeOfStack, cnt):
	if cnt == sizeOfStack // 2:
		s.pop()
		return
	x = s.pop()
	delete(s, sizeOfStack, cnt + 1)
	s.append(x)

class Solution:

	def deleteMid(self, s, sizeOfStack):
		delete(s, sizeOfStack, 0)
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):

		def fun(stack, count, c):
			if c == count:
				stack.pop()
				return
			temp = stack.pop()
			c = c + 1
			fun(stack, count, c)
			stack.append(temp)
			return stack
		stack = s
		mid = (len(stack) - 1) // 2
		count = len(stack) - 1 - mid
		c = 0
		return fun(stack, count, c)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		v = sizeOfStack
		if sizeOfStack % 2 == 0:
			s.pop(v // 2 - 1)
		else:
			s.pop((v + 1) // 2 - 1)


class Solution:

	def deleteMid(self, s, sizeOfStack):

		def delete(stack, count, pos):
			if len(stack) == 0:
				return
			if count == pos:
				stack.pop(pos - 1)
				return
			top = s[-1]
			s.pop()
			delete(s, count + 1, pos)
			s.append(top)
		count = 1
		pos = (sizeOfStack + 1) // 2
		delete(s, count, pos)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		i = int((sizeOfStack + 1) / 2)
		stack = []
		if sizeOfStack % 2 == 0:
			x = 0
		else:
			x = 1
		while x < i:
			temp = s.pop()
			stack.append(temp)
			x += 1
		s.pop()
		while stack:
			temp = stack.pop()
			s.append(temp)
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		self.deleteMiddle(s, sizeOfStack, 0)
		return s

	def deleteMiddle(self, s, sizeOfStack, curr):
		if len(s) == 0 or curr == sizeOfStack:
			return
		element = s[0]
		s.pop(0)
		curr = curr + 1
		self.deleteMiddle(s, sizeOfStack, curr)
		if curr != int((sizeOfStack + 1) / 2):
			s.insert(0, element)


class Solution:

	def deleteMid(self, s, sizeOfStack):

		def rec(s, mid):
			if len(s) == mid + 1:
				s.pop()
				return s
			last = s[-1]
			s.pop()
			rec(s, mid)
			s.append(last)
			return s
		if len(s) % 2 == 0:
			mid = len(s) // 2 - 1
		else:
			mid = len(s) // 2
		return rec(s, mid)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		k = sizeOfStack // 2

		def mid(a, z):
			if z == 0:
				a.pop()
				return
			val = a[-1]
			a.pop()
			mid(a, z - 1)
			a.append(val)
			return
		mid(s, k)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		k = (sizeOfStack - 1) // 2
		s.pop(k)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		mid = sizeOfStack // 2

		def solve(s, mid):
			if len(s) == 0:
				return
			top = s.pop()
			solve(s, mid - 1)
			if mid != 0:
				s.append(top)
			return
		return solve(s, mid)


from math import ceil

class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack % 2 != 0:
			a = sizeOfStack // 2
		else:
			a = sizeOfStack // 2 - 1
		s[:] = s[:a] + s[a + 1:]


class Solution:

	def swap(self, s, i, j):
		(s[i], s[j]) = (s[j], s[i])

	def deleteMid(self, s, sizeOfStack):
		mid = (sizeOfStack - 1) // 2
		for i in range(mid, sizeOfStack - 1):
			self.swap(s, i, i + 1)
		s.pop()


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if len(s) % 2 == 0:
			s.pop(int(len(s) / 2 - 1))
		else:
			s.pop(int(len(s) // 2))
		return s


class Solution:

	def deleteMid(self, s, sizeOfStack):
		if s is None:
			return
		mid = sizeOfStack // 2
		new = []
		for i in range(mid + 1):
			new.append(s.pop())
		new.pop()
		for i in range(len(new)):
			s.append(new.pop())


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		stack = []
		middle = math.ceil((sizeOfStack + 1) / 2)
		for i in range(middle):
			stack.append(s.pop())
		stack.pop()
		for i in range(middle - 1):
			s.append(stack.pop())
		return s


import math

class Solution:

	def deleteMid(self, s, n):
		s2 = []
		middle = math.ceil((n + 1) / 2)
		for i in range(middle):
			s2.append(s.pop())
		s2.pop()
		for i in range(middle - 1):
			s.append(s2.pop())
		return s


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack % 2 == 0:
			midIndex = math.ceil(sizeOfStack / 2)
		else:
			midIndex = math.ceil(sizeOfStack / 2) - 1
		tempStack = []
		for i in range(0, midIndex + 1):
			tempStack.append(s[-1])
			s.pop()
		tempStack.pop()
		tempStack.reverse()
		for ele in tempStack:
			s.append(ele)


class Solution:

	def deleteMid(self, s, sizeOfStack):
		arr = []
		index = int(sizeOfStack / 2)
		for i in range(index):
			arr.append(s.pop())
		s.pop()
		for i in range(len(arr)):
			s.append(arr.pop())
		return s


class Solution:

	def deleteMid_util(self, s, sizeOfStack, current):
		if current == sizeOfStack // 2:
			s.pop()
			return
		x = s.pop()
		current += 1
		self.deleteMid_util(s, sizeOfStack, current)
		s.append(x)

	def deleteMid(self, s, sizeOfStack):
		self.deleteMid_util(s, sizeOfStack, 0)


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		middle = math.ceil((sizeOfStack + 1) / 2)
		new_stack = []
		r = sizeOfStack
		if sizeOfStack % 2 == 0:
			while middle <= r:
				new_stack.append(s.pop())
				r -= 1
		else:
			while middle < r:
				new_stack.append(s.pop())
				r -= 1
		s.pop()
		while len(new_stack):
			s.append(new_stack.pop())
		return s


class Solution:

	def solve(self, s, n, mid, st, ans):
		if n == 0:
			return
		self.solve(s, n - 1, mid, st, ans)
		if n != mid + 1:
			st.append(s.pop())
		else:
			s.pop()
		return

	def deleteMid(self, s, sizeOfStack):
		n = sizeOfStack
		mid = n // 2
		ans = []
		st = []
		self.solve(s, n, mid, st, ans)
		for i in range(len(st)):
			s.append(st.pop())
		return s


class Solution:

	def deleteMid(self, list, size):
		if not list:
			return
		else:
			mid = size // 2
			sub_stack = []
			for i in range(mid + 1):
				sub_stack.append(list.pop())
			sub_stack.pop()
			for i in range(len(sub_stack)):
				list.append(sub_stack.pop())
			return list


import math

class Solution:

	def deleteMid(self, stack, ss):

		def solve(stack, k):
			if k == 1:
				stack.pop()
				return stack
			else:
				ele = stack[-1]
				stack.pop()
				solve(stack, k - 1)
				stack.append(ele)
				return stack
		if len(stack) == 0:
			return stack
		k = ss // 2 + 1
		s = solve(stack, k)
		return s


import math

class Solution:

	def deleteMid(self, s, sizeOfStack):
		if sizeOfStack % 2 != 0:
			s.pop(math.ceil(sizeOfStack // 2))
		else:
			s.pop(math.ceil(sizeOfStack // 2) - 1)