Easy and Simple Solution
Please Like ❤️IntuitionTo remove the outermost parentheses of each valid primitive string in a valid parentheses string, the approach revolves around maintainin
```java
class Solution {
    public String removeOuterParentheses(String s) {
        StringBuilder str = new StringBuilder();
        int count = 0;
        for (char ch : s.toCharArray()) {
            if (ch == '(') {
                if (count > 0) str.append("(");
                count++;
            } else {
                count--;
                if (count > 0) str.append(")");
            }
        }
        return str.toString();
    }
}
```

# Please Like ❤️  
![Please Like](https://media.tenor.com/heEyHbV8iaUAAAAM/puss-in-boots-shrek.gif)

# Intuition  
To remove the outermost parentheses of each valid primitive string in a valid parentheses string, the approach revolves around maintaining a counter to track the depth of parentheses.

# Approach  
1. Use a counter `count` to track the depth of parentheses:
   - Increment the counter for each opening parenthesis `(`.
   - Decrement the counter for each closing parenthesis `)`.
2. Add characters to the result string only if they are not part of the outermost parentheses:
   - Append `(` to the result if `count > 0` before incrementing.
   - Append `)` to the result if `count > 0` after decrementing.

# Complexity  
- **Time complexity**:  
  $$O(n)$$, where $$n$$ is the length of the input string `s`, as we iterate through the string once.  

- **Space complexity**:  
  $$O(n)$$, due to the usage of the `StringBuilder` to store the result.
['Java']