Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid Parentheses #43

Closed
Tracked by #100
fkdl0048 opened this issue Sep 30, 2024 · 1 comment
Closed
Tracked by #100

Valid Parentheses #43

fkdl0048 opened this issue Sep 30, 2024 · 1 comment
Assignees
Labels
Milestone

Comments

@fkdl0048
Copy link
Owner

fkdl0048 commented Sep 30, 2024

using namespace std;

class Solution {
public:
    bool isValid(string s) {
        stack<char> bucket;

        for (char c : s){
            if (c == '(' || c == '{' || c == '['){
                bucket.push(c);
            }
            else {
                if (bucket.empty() || !isParentheses(bucket.top(), c)) {
                    return false;
                }
                bucket.pop();
            }
        }

        return bucket.empty();
    }
private:
    bool isParentheses(char left, char right){
        if (left == '(' && right == ')')
            return true;
        if (left == '{' && right == '}')
            return true;
        if (left == '[' && right == ']')
            return true;
        return false;
    }
};
  • 기본적인 스택 문제
@fkdl0048 fkdl0048 mentioned this issue Sep 30, 2024
7 tasks
@fkdl0048 fkdl0048 self-assigned this Sep 30, 2024
@fkdl0048 fkdl0048 added this to Todo Sep 30, 2024
@github-project-automation github-project-automation bot moved this to Todo in Todo Sep 30, 2024
@fkdl0048 fkdl0048 moved this from Todo to In Progress in Todo Sep 30, 2024
@fkdl0048 fkdl0048 moved this from In Progress to Two-Week Plan in Todo Sep 30, 2024
@fkdl0048 fkdl0048 added this to the LeetCode milestone Sep 30, 2024
@fkdl0048 fkdl0048 closed this as completed Oct 4, 2024
@github-project-automation github-project-automation bot moved this from Two-Week Plan to Done in Todo Oct 4, 2024
@fkdl0048
Copy link
Owner Author

fkdl0048 commented Oct 4, 2024

  • C++ std에 대한 사용법 부족이 좀 있는듯, 많이 풀어보면서 확장해야 할 것 같음

@fkdl0048 fkdl0048 mentioned this issue Oct 15, 2024
47 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

1 participant