0% found this document useful (0 votes)
14 views1 page

3 RD

The code takes a string as input, replaces each '(' with -1 and ')' with +1, prints the resulting list, then defines a function to iteratively delete matching pairs of -1 and 1 from the list starting from a given index.

Uploaded by

rineeth m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

3 RD

The code takes a string as input, replaces each '(' with -1 and ')' with +1, prints the resulting list, then defines a function to iteratively delete matching pairs of -1 and 1 from the list starting from a given index.

Uploaded by

rineeth m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

s=input()

s=[-1 if(x=='(') else +1 for x in s]


n=len(s)
print(s)

def solve(s,ind,n):
found=1
i=ind
while(found)
if(s[i]==-1):
if(s[i+1]==1):
del

You might also like