class Parenthesis {
public:
    bool chkParenthesis(string A, int n) {
        // write code here
        stack<char> heap;
        for (int i = 0; i < n; i ++)
        {
            if (A[i] == '(')
            {
                heap.push(A[i]);
            }
            else if (A[i] == ')' && heap.size())
            {
                heap.pop();
            }
            else {
                return false;
            }
        }
        if (heap.empty())
            return true;
        else return false;
    }
};