Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://www.codingninjas.com/codestudio/problems/redundant-brackets_975473?leftPanelTab=1
- def findRedundantBrackets(s:str):
- st=[]
- if s=='':return False
- sym='(+-/*' #no close brack
- for i in s:
- if i in sym :#any other symb than close br
- st.append(i)
- elif i==')':
- if st[-1]=='(':
- return True
- else:
- while st[-1]!='(':st.pop()
- st.pop()
- else:
- continue #skipping variables
- return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement