Java♨️  || 2 Approaches(With+Without Stack) ✅
The main thing is --> (()()) --> If the stack(or counter) is greater than 1 then include "(" and ")" in answer else don\'t include as we need to remove outermos
**The main thing is --> (()()) --> If the stack(or counter) is greater than 1 then include "(" and ")" in answer else don\'t include as we need to remove outermost parenthesis... If you find the solution helpful please  upvote :)**\n\n**Without stack approach -->**\n```\nclass Solution {\n    public String removeOuterParentheses(String s) {\n        StringBuilder sb = new StringBuilder();\n        int level = 0;\n        for(int i = 0;i<s.length();i++){\n            if(s.charAt(i) == \'(\'){\n                level++;\n            }\n            if(level > 1){\n                sb.append(s.charAt(i));\n            }\n            if(s.charAt(i) == \')\'){\n                level--;\n            }\n        }\n        return sb.toString();\n    }\n}\n```\n\n\n**With Stack Approach-->**\n```\nclass Solution {\n    public String removeOuterParentheses(String s) {\n        StringBuilder sb = new StringBuilder();\n        Stack<Character> st = new Stack<>();\n        for(char c : s.toCharArray()){\n            if(st.isEmpty() && c == \'(\'){\n                st.push(\'(\');\n            }\n            else if(!st.isEmpty() && c == \'(\'){\n                st.push(c);\n                sb.append(c);\n            }\n            else if(st.size() >1 && c == \')\'){\n                st.pop();\n                sb.append(c);\n            }\n            else if(st.size() == 1 && c == \')\'){\n                st.pop();\n            }\n        }\n        return sb.toString();\n    }\n}\n\n```
['Stack', 'Java']