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

CLASS 2: 균형잡힌 세상 - [4949] #10

Closed
Tracked by #2
fkdl0048 opened this issue Aug 14, 2023 · 0 comments
Closed
Tracked by #2

CLASS 2: 균형잡힌 세상 - [4949] #10

fkdl0048 opened this issue Aug 14, 2023 · 0 comments
Assignees
Labels

Comments

@fkdl0048
Copy link
Owner

fkdl0048 commented Aug 14, 2023

CLASS 2: 균형잡힌 세상 - [4949]

namespace baekjoon_4949
{
    public class ValidStringReader
    {
        private char[] brackets;

        public bool Read(string input)
        {
            brackets = new char[100];

            int index = 0;
            foreach (var c in input)
            {
                if (c == '(' || c == '[')
                {
                    brackets[index++] = c;
                }
                else if (c == ')')
                {
                    if (index == 0 || brackets[--index] != '(')
                    {
                        return false;
                    }
                }
                else if (c == ']')
                {
                    if (index == 0 || brackets[--index] != '[')
                    {
                        return false;
                    }
                }
            }

            return index == 0;
        }
    }   

    public class Program
    {
        public static void Main(string[] args)
        {
            var reader = new ValidStringReader();
            while (true)
            {
                var input = System.Console.ReadLine();
                if (input == ".")
                {
                    break;
                }

                System.Console.WriteLine(reader.Read(input) ? "yes" : "no");
            }
        }
    }
}
@fkdl0048 fkdl0048 mentioned this issue Aug 14, 2023
6 tasks
@fkdl0048 fkdl0048 self-assigned this Aug 14, 2023
@fkdl0048 fkdl0048 added this to Todo Aug 14, 2023
@fkdl0048 fkdl0048 added this to the Solved.ac Class milestone Aug 14, 2023
@github-project-automation github-project-automation bot moved this to Todo in Todo Aug 14, 2023
@fkdl0048 fkdl0048 moved this from Todo to Two-Week Plan in Todo Aug 14, 2023
@fkdl0048 fkdl0048 moved this from Two-Week Plan to In Progress in Todo Aug 30, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Todo Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

1 participant