# 921. Minimum Add to Make Parentheses Valid

```java
class Solution {
    public int minAddToMakeValid(String s) {
        int result = 0;
        //when see a '(', need++ meaning will need a ')';
        int need =0;
        for (int i=0;i<s.length(); i++){
            if(s.charAt(i)=='('){
                need++;
            }else{ //if see')'
                if(need==0){
                    result++;
                }else{
                    need--;
                }
            }
        }
        return result+need;
    }
}
```
