# PDA for $L= \{w : n_a(w)+n_b(w) = 2n_c(w)\}$

I'm pretty new to the PDA topic.

How do I construct an NPDA for the language $$L= \{w : n_a(w)+n_b(w) = 2n_c(w)\}.$$

I've tried all the possibilities, but I still somehow end up accepting all words.

The idea is to store a counter $$n_a(w) + n_b(w) - 2n_c(w)$$ in the stack. If this number is positive, say $$x$$, we want to have $$x$$ many P's on the stack (and nothing else). If this number is negative, say $$-y$$, we want to have $$y$$ many N's on the stack (and nothing else). Otherwise we want to have a special indicator $$O$$ on the stack. At the end, we check that the stack consists of $$O$$.