MCPcopy Create free account
hub / github.com/cp-algorithms/cp-algorithms / balanced

Function balanced

test/test_balanced_brackets.cpp:12–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "kth_balances_bracket_multiple.h"
11
12bool balanced(string s) {
13 stack<char> st;
14 for (char c : s) {
15 if (c == '(' || c == '[') {
16 st.push(c);
17 } else {
18 if (st.empty())
19 return false;
20 if (c == ')' && st.top() != '(')
21 return false;
22 if (c == ']' && st.top() != '[')
23 return false;
24 st.pop();
25 }
26 }
27 return st.empty();
28}
29
30void find_all_permutation(string s, vector<string> & all) {
31 do {

Callers 1

find_all_permutationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected