Sha256: f10d8e55bb002ccb3ab9e1361f27853e44dcff0c949c83e2cb408bcd7fe9e544
Contents?: true
Size: 554 Bytes
Versions: 182
Compression:
Stored size: 554 Bytes
Contents
#include "bracket_push.h" #include <stack> using namespace std; namespace bracket_push { bool check(string const& expression) { const string open("({["); const string close(")}]"); stack<char> st; for (const char c : expression) { if (open.find(c) != string::npos) { st.push(c); } else if (close.find(c) != string::npos) { if (st.empty() || st.top() != open[close.find(c)]) { return false; } st.pop(); } } return st.empty(); } }
Version data entries
182 entries across 182 versions & 1 rubygems