Skip to content

Instantly share code, notes, and snippets.

@vitkarpov
Created March 2, 2020 14:01
Show Gist options
  • Save vitkarpov/0d1fa4f76934808bfee8b286c38f823a to your computer and use it in GitHub Desktop.
Save vitkarpov/0d1fa4f76934808bfee8b286c38f823a to your computer and use it in GitHub Desktop.
Valid Parentheses LeetCode grader
#include <stdexcept>
#include <string>
#include <vector>
using namespace std;
class Solution {
public:
bool isValid(string s) {
// твой код здесь
}
};
int main() {
vector<pair<string, bool>> tests = {{"()", true},
{"()[]{}", true},
{"(]", false},
{"([)]", false},
{"{[]}", true}};
Solution solution;
for (auto v : tests) {
assert(solution.isValid(v.first) == v.second);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment