From c793787319e6243835ad653016e131ee66af8282 Mon Sep 17 00:00:00 2001 From: aslesha <cb.en.u4cse16259@cb.students.amrita.edu> Date: Wed, 19 Dec 2018 12:46:23 +0530 Subject: [PATCH] Add new file --- lab2/cse16259_e2_10.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lab2/cse16259_e2_10.py diff --git a/lab2/cse16259_e2_10.py b/lab2/cse16259_e2_10.py new file mode 100644 index 0000000..2197dd5 --- /dev/null +++ b/lab2/cse16259_e2_10.py @@ -0,0 +1,20 @@ +def maximum(s): + max = 0 + maxi = 0 + n=len(s) + for i in range(n): + if (str[i] == '('): + max+=1; + if(max>maxi): + maxi=max + elif (str[i] == ')'): + if(max > 0): + max-=1; + else: + return -1; + if(max !=0): + print("Not Valid") + return -1; + return maxi; +s=input("Enter a string") +print (maximum(s)) -- GitLab