algo

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub kuhaku-space/algo

:warning: lib/string/parenthesis.hpp

Code

#pragma once
#include <string>

bool is_correct_parenthesis_sequences(const std::string &s) {
    int cnt = 0;
    for (char c : s) {
        if (c == '(') ++cnt;
        else if (cnt == 0) return false;
        else --cnt;
    }
    return cnt == 0;
}
#line 2 "lib/string/parenthesis.hpp"
#include <string>

bool is_correct_parenthesis_sequences(const std::string &s) {
    int cnt = 0;
    for (char c : s) {
        if (c == '(') ++cnt;
        else if (cnt == 0) return false;
        else --cnt;
    }
    return cnt == 0;
}
Back to top page