fork(2) download
  1. def removeNestedParentheses(input):
  2. ret = ''
  3. skip = 0
  4. for i in input:
  5. if i == '(':
  6. skip += 1
  7. elif i == ')'and skip > 0:
  8. skip -= 1
  9. elif skip == 0:
  10. ret += i
  11. return ret
  12.  
  13. x = removeNestedParentheses('stuff (inside (nested) brackets) (and (some(are)) here) here')
  14. print x
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
stuff   here