diff --git a/Solutions/Even Up Solitaire/evenup.cpp b/Solutions/Even Up Solitaire/evenup.cpp new file mode 100644 index 00000000..81b275e2 --- /dev/null +++ b/Solutions/Even Up Solitaire/evenup.cpp @@ -0,0 +1,23 @@ +#include +#include + +using namespace std; + +int main() { + int n; + cin >> n; + + stack cards; + while(n--) { + int card; + cin >> card; + if(!cards.empty() && !((cards.top() + card) % 2)) { + cards.pop(); + continue; + } + cards.push(card); + } + + cout << cards.size(); + return 0; +} \ No newline at end of file