Easy way explanation every step
if your current char is \'(\' then two things happen one is stack is empty then don\'t add char in result means it indicates no outer parentheses is present.if 
# if your current char is \'(\' then two things happen one is stack is empty then don\'t add char in result means it indicates no outer parentheses is present.if your stack is not empty then definitely have a outer parentheses this time add char into results\n```\nif c == \'(\':\n                if stack:\n                    res.append(c)\n                stack.append(c)\n\n```\n# when current char is ")" and popfrom a stack "(" .two things happen if your stack is empty it means no outer parentheses.if not empty then outer parentheses is present.so add into result .\n```\nelse:\n                stack.pop()\n                if stack:\n                    res.append(c)\n```\n# Easy example\n```\nYour input\n"()()()()"\nstdout\nposition= 0  current char= (  stack=  []\nresult= \n\nposition= 1  current char= )  stack=  [\'(\']\nresult= \n\nposition= 2  current char= (  stack=  []\nresult= \n\nposition= 3  current char= )  stack=  [\'(\']\nresult= \n\nposition= 4  current char= (  stack=  []\nresult= \n\nposition= 5  current char= )  stack=  [\'(\']\nresult= \n\nposition= 6  current char= (  stack=  []\nresult= \n\nposition= 7  current char= )  stack=  [\'(\']\nresult= \n\n\nOutput\n""\n\n\n```\n# simple Example\n```\nYour input\n"(())"\nstdout\nposition= 0  current char= (  stack=  []\nresult= \n\nposition= 1  current char= (  stack=  [\'(\']\nresult= (\n\nposition= 2  current char= )  stack=  [\'(\', \'(\']\nresult= ()\n\nposition= 3  current char= )  stack=  [\'(\']\nresult= ()\n\n\nOutput\n"()"\nExpected\n"()"\n```\n# hard example\n```\n"(((())))"\nstdout\nposition= 0  current char= (  stack=  []\nresult= \n\nposition= 1  current char= (  stack=  [\'(\']\nresult= (\n\nposition= 2  current char= (  stack=  [\'(\', \'(\']\nresult= ((\n\nposition= 3  current char= (  stack=  [\'(\', \'(\', \'(\']\nresult= (((\n\nposition= 4  current char= )  stack=  [\'(\', \'(\', \'(\', \'(\']\nresult= ((()\n\nposition= 5  current char= )  stack=  [\'(\', \'(\', \'(\']\nresult= ((())\n\nposition= 6  current char= )  stack=  [\'(\', \'(\']\nresult= ((()))\n\nposition= 7  current char= )  stack=  [\'(\']\nresult= ((()))\n\n\nOutput\n"((()))"\nExpected\n"((()))"\n```\n# complex example\n```\nYour input\n"(()())(())"\nstdout\nposition= 0  current char= (  stack=  []\nresult= \n\nposition= 1  current char= (  stack=  [\'(\']\nresult= (\n\nposition= 2  current char= )  stack=  [\'(\', \'(\']\nresult= ()\n\nposition= 3  current char= (  stack=  [\'(\']\nresult= ()(\n\nposition= 4  current char= )  stack=  [\'(\', \'(\']\nresult= ()()\n\nposition= 5  current char= )  stack=  [\'(\']\nresult= ()()\nposition= 6  current char= (  stack=  []\nresult= ()()\n\nposition= 7  current char= (  stack=  [\'(\']\nresult= ()()(\n\nposition= 8  current char= )  stack=  [\'(\', \'(\']\nresult= ()()()\n\nposition= 9  current char= )  stack=  [\'(\']\nresult= ()()()\n\nOutput\n"()()()"\nExpected\n"()()()"\n\n```\n\n```\n\nclass Solution(object):\n    def removeOuterParentheses(self, S):\n        """\n        :type S: str\n        :rtype: str\n        """\n        res,stack = [],[]\n        for i,c in enumerate (S):\n            \n            if c == \'(\':\n                if stack:\n                    res.append(c)\n                stack.append(c)\n            else:\n                stack.pop()\n                if stack:\n                    res.append(c)\n           \n        return \'\'.join(res)\n        \n        \n```
['Python']