From 393ff878e8282d8352355e2892a892c8c533afc6 Mon Sep 17 00:00:00 2001 From: D Vengatesh <cb.en.u4cse16261@cb.students.amrita.edu> Date: Tue, 11 Dec 2018 23:10:00 +0530 Subject: [PATCH] ex2 q10 done --- CSE16261_Ex02_10.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 CSE16261_Ex02_10.py diff --git a/CSE16261_Ex02_10.py b/CSE16261_Ex02_10.py new file mode 100644 index 0000000..935bcf2 --- /dev/null +++ b/CSE16261_Ex02_10.py @@ -0,0 +1,15 @@ +s=input("Enter the string:") +max1=0 +curr_max=0 +for i in range(len(s)): + if s[i]=='(': + curr_max+=1 + if(curr_max>max1): + max1=curr_max + elif s[i]==')': + curr_max-=1 +if curr_max==0: + print(max1) +else : + print("mismatch") + print(max1) -- GitLab