Given a string of balanced expression, find if it contains a redundant parenthesis or not. A set of parenthesis are redundant if the same sub-expression is surrounded by unnecessary or multiple brackets. Print Yes if redundant, else No.
Note: Expression may contain + , - , *, and / operators. Given expression is valid and there are no white spaces present.
Example 1:
Input:
exp = ((a+b))
Output:
Yes
Explanation:
((a+b)) can reduced to (a+b).
Example 2:
Input:
exp = (a+b+(c+d))
Output:
No
Explanation:
(a+b+(c+d)) doesn't have any redundant or multiple
brackets.
Your task:
You don't have to read input or print anything. Your task is to complete the function checkRedundancy() which takes the string s as input and returns 1 if it contains redundant parentheses else 0.
Constraints:
1<=|str|<=10^{4}
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)

Difficulty: MEDIUM
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)

Starter code:
class Solution():



    def checkRedundancy(self, s):

    

        #your code goes here

Solutions:
class Solution:

	def checkRedundancy(self, s):
		li = []
		ch = 0
		for k in s:
			if k != ')':
				li.append(k)
			else:
				i = len(li)
				c = 0
				for j in range(i - 1, -1, -1):
					if li[j] != '(':
						c = c + 1
						li.pop()
					else:
						break
				li.pop()
				if c <= 1:
					return 1
		if ch == 0:
			return 0


class Solution:

	def checkRedundancy(self, s):
		stack = []
		for i in s:
			if i in '(+*/-':
				stack.append(i)
			elif i == ')':
				is_redundant = True
				while stack[-1] != '(':
					if stack[-1] in '*+-/':
						is_redundant = False
					stack.pop()
				stack.pop()
				if is_redundant:
					return 1
		return 0


class Solution:

	def checkRedundancy(self, s):
		st = []
		for i in s:
			if i == '(' or i == '+' or i == '-' or (i == '*') or (i == '/'):
				st.append(i)
			elif i == ')':
				if st[-1] == '(':
					return 1
				else:
					while st and st[-1] != '(':
						st.pop()
					st.pop()
		return 0


class Solution:

	def checkRedundancy(self, s):
		stack = []
		sign = '*-+/'
		for elm in s:
			if elm in sign or elm == '(':
				stack.append(elm)
			elif elm == ')':
				if stack[-1] not in sign:
					return 1
				while len(stack) > 0 and stack[-1] in sign:
					stack.pop()
				stack.pop()
		return 0


class Solution:

	def checkRedundancy(self, s):
		op = {'+', '-', '*', '/'}
		st = [-1]
		for ele in s:
			if ele == '(' or ele in op:
				st.append(ele)
			elif ele == ')':
				top = st[-1]
				if top in op:
					while st[-1] != -1 and st[-1] in op:
						st.pop()
					else:
						st.pop()
				else:
					return 1
		else:
			return 0


class Solution:

	def checkRedundancy(self, s):
		st = []
		for i in s:
			if i == '(' or i == '+' or i == '-' or (i == '*') or (i == '/'):
				st.append(i)
			elif i == ')':
				flag = True
				while st[-1] != '(':
					char = st[-1]
					if char == '+' or char == '-' or char == '*' or (char == '/'):
						flag = False
					st.pop()
				if flag == True:
					return 1
				st.pop()
		return 0


class Solution:

	def checkRedundancy(self, s):
		stk = []
		for i in s:
			if i == '(' or i in ['+', '-', '/', '*']:
				stk.append(i)
			elif i == ')':
				isRedundant = True
				while stk[-1] != '(':
					x = stk[-1]
					if x in ['+', '-', '/', '*']:
						isRedundant = False
					stk.pop()
				if isRedundant:
					return 1
				stk.pop()
		return 0


class Solution:

	def checkRedundancy(self, s):
		stack = []
		for i in s:
			if i == '(' or i in ['+', '-', '/', '*']:
				stack.append(i)
			elif i == ')':
				red = True
				while stack[-1] != '(':
					x = stack[-1]
					if x in ['+', '-', '/', '*']:
						red = False
					stack.pop()
				if red:
					return 1
				stack.pop()
		return 0


class Solution:

	def checkRedundancy(self, s):
		st = []
		lvl = 0
		checked = False
		for i in s:
			if i == '(':
				lvl += 1
				checked = False
			elif i in ['+', '-', '/', '*']:
				if not checked:
					checked = True
					st.append(lvl)
			elif i == ')':
				if len(st) == 0:
					return 1
				ch = st.pop()
				if lvl == ch:
					lvl -= 1
					if len(st) == 0 or st[-1] != lvl:
						checked = False
					else:
						checked = True
				else:
					return 1
		return 0


class Solution:

	def checkRedundancy(self, s):
		stack = []
		op = ['+', '-', '*', '/']
		for i in s:
			if i == ')' and len(stack) > 0:
				flg = 1
				while len(stack) > 0 and stack[-1] != '(':
					ch = stack[-1]
					if ch in op:
						flg = 0
					stack.pop()
				if flg == 1:
					return 1
				stack.pop()
			else:
				stack.append(i)
		return 0


from collections import deque

class Solution:

	def checkRedundancy(self, s):
		stack = deque()
		for i in s:
			if i != ')':
				stack.append(i)
			elif stack:
				flag = 0
				while stack[-1] != '(':
					popped = stack.pop()
					if popped in ['+', '-', '*', '/']:
						flag = 1
				stack.pop()
				if flag == 0:
					return 1
		return 0


class Solution:

	def checkRedundancy(self, arr):
		st = []
		list1 = ['+', '-', '*', '/']
		for i in range(0, len(arr)):
			if arr[i] == '(' or arr[i] in list1:
				st.append(arr[i])
			if arr[i] == ')':
				if st[-1] == '(':
					return 1
				else:
					while st[-1] != '(':
						st.pop()
					st.pop()
		return 0


class Solution:

	def checkRedundancy(self, s):
		a = list(s)
		b = []
		op = ['+', '-', '*', '/']
		for i in range(0, len(a), 1):
			if a[i] == '(' or a[i] in op:
				b.append(a[i])
			if a[i] == ')':
				if b[-1] == '(':
					return 1
				else:
					while b[-1] != '(':
						b.pop()
					b.pop()
		return 0


class Solution:

	def checkRedundancy(self, s):
		stack = []
		for ch in s:
			if ch == ')':
				if stack[-1] == '(':
					return 1
				else:
					while stack[-1] != '(':
						stack.pop()
					stack.pop()
			elif ch in ['(', '+', '-', '*', '/']:
				stack.append(ch)
		return 0


class Solution:

	def checkRedundancy(self, s):
		stk = []
		loi = None
		lci = None
		for i in range(len(s)):
			if s[i] == '(':
				stk.append(i)
			elif s[i] == ')':
				charI = stk.pop()
				if loi and lci:
					if loi - charI == 1 and i - lci == 1 or lci - loi == 2:
						return 1
				lci = i
				loi = charI
		return 0


class Solution:

	def checkRedundancy(self, s):
		st = []
		op = ['+', '*', '/', '-']
		for i in range(0, len(s)):
			if s[i] == '(' or s[i] in op:
				st.append(s[i])
			if s[i] == ')':
				if st[-1] == '(':
					return 1
				else:
					while st[-1] != '(':
						st.pop()
					st.pop()
		return 0


class Solution:

	def checkRedundancy(self, s):
		st = []
		count = 0
		for i in s:
			if i == ')':
				top = st.pop()
				ele = 0
				while top != '(':
					ele += 1
					top = st.pop()
				if ele <= 1:
					return 1
			else:
				st.append(i)
		return 0