|
| 1 | +{ |
| 2 | + "problem_name": "valid_parentheses", |
| 3 | + "solution_class_name": "Solution", |
| 4 | + "problem_number": "20", |
| 5 | + "problem_title": "Valid Parentheses", |
| 6 | + "difficulty": "Easy", |
| 7 | + "topics": "String, Stack", |
| 8 | + "tags": ["grind-75"], |
| 9 | + "readme_description": "Given a string `s` containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid.\n\nAn input string is valid if:\n\n1. Open brackets must be closed by the same type of brackets.\n2. Open brackets must be closed in the correct order.\n3. Every close bracket has a corresponding open bracket of the same type.", |
| 10 | + "readme_examples": [ |
| 11 | + { "content": "```\nInput: s = \"()\"\nOutput: true\n```" }, |
| 12 | + { "content": "```\nInput: s = \"()[]{}\"\nOutput: true\n```" }, |
| 13 | + { "content": "```\nInput: s = \"(]\"\nOutput: false\n```" }, |
| 14 | + { "content": "```\nInput: s = \"([])\"\nOutput: true\n```" }, |
| 15 | + { "content": "```\nInput: s = \"([)]\"\nOutput: false\n```" } |
| 16 | + ], |
| 17 | + "readme_constraints": "- `1 <= s.length <= 10^4`\n- `s` consists of parentheses only `'()[]{}'`.", |
| 18 | + "readme_additional": "", |
| 19 | + "solution_imports": "", |
| 20 | + "solution_methods": [ |
| 21 | + { "name": "is_valid", "parameters": "s: str", "return_type": "bool", "dummy_return": "False" } |
| 22 | + ], |
| 23 | + "test_imports": "import pytest\nfrom leetcode_py.test_utils import logged_test\nfrom .solution import Solution", |
| 24 | + "test_class_name": "ValidParentheses", |
| 25 | + "test_helper_methods": [ |
| 26 | + { "name": "setup_method", "parameters": "", "body": "self.solution = Solution()" } |
| 27 | + ], |
| 28 | + "test_methods": [ |
| 29 | + { |
| 30 | + "name": "test_is_valid", |
| 31 | + "parametrize": "s, expected", |
| 32 | + "parametrize_typed": "s: str, expected: bool", |
| 33 | + "test_cases": "[('()', True), ('()[]{}', True), ('(]', False), ('([])', True), ('([)]', False), ('', True), ('(', False), (')', False), ('{[()]}', True), ('{[(])}', False)]", |
| 34 | + "body": "result = self.solution.is_valid(s)\nassert result == expected" |
| 35 | + } |
| 36 | + ], |
| 37 | + "playground_imports": "from solution import Solution", |
| 38 | + "playground_test_case": "# Example test case\ns = '()'\nexpected = True", |
| 39 | + "playground_execution": "result = Solution().is_valid(s)\nresult", |
| 40 | + "playground_assertion": "assert result == expected" |
| 41 | +} |
0 commit comments