|
| 1 | +{ |
| 2 | + "problem_name": "ransom_note", |
| 3 | + "solution_class_name": "Solution", |
| 4 | + "problem_number": "383", |
| 5 | + "problem_title": "Ransom Note", |
| 6 | + "difficulty": "Easy", |
| 7 | + "topics": "Hash Table, String, Counting", |
| 8 | + "tags": ["grind-75"], |
| 9 | + "readme_description": "Given two strings `ransomNote` and `magazine`, return `true` if `ransomNote` can be constructed by using the letters from `magazine` and `false` otherwise.\n\nEach letter in `magazine` can only be used once in `ransomNote`.", |
| 10 | + "readme_examples": [ |
| 11 | + { "content": "```\nInput: ransomNote = \"a\", magazine = \"b\"\nOutput: false\n```" }, |
| 12 | + { "content": "```\nInput: ransomNote = \"aa\", magazine = \"ab\"\nOutput: false\n```" }, |
| 13 | + { "content": "```\nInput: ransomNote = \"aa\", magazine = \"aab\"\nOutput: true\n```" } |
| 14 | + ], |
| 15 | + "readme_constraints": "- 1 <= ransomNote.length, magazine.length <= 10^5\n- ransomNote and magazine consist of lowercase English letters.", |
| 16 | + "readme_additional": "", |
| 17 | + "solution_imports": "", |
| 18 | + "solution_methods": [ |
| 19 | + { |
| 20 | + "name": "can_construct", |
| 21 | + "parameters": "ransom_note: str, magazine: str", |
| 22 | + "return_type": "bool", |
| 23 | + "dummy_return": "False" |
| 24 | + } |
| 25 | + ], |
| 26 | + "test_imports": "import pytest\nfrom leetcode_py.test_utils import logged_test\nfrom .solution import Solution", |
| 27 | + "test_class_name": "RansomNote", |
| 28 | + "test_helper_methods": [ |
| 29 | + { "name": "setup_method", "parameters": "", "body": "self.solution = Solution()" } |
| 30 | + ], |
| 31 | + "test_methods": [ |
| 32 | + { |
| 33 | + "name": "test_can_construct", |
| 34 | + "parametrize": "ransom_note, magazine, expected", |
| 35 | + "parametrize_typed": "ransom_note: str, magazine: str, expected: bool", |
| 36 | + "test_cases": "[('a', 'b', False), ('aa', 'ab', False), ('aa', 'aab', True), ('aab', 'baa', True)]", |
| 37 | + "body": "result = self.solution.can_construct(ransom_note, magazine)\nassert result == expected" |
| 38 | + } |
| 39 | + ], |
| 40 | + "playground_imports": "from solution import Solution", |
| 41 | + "playground_test_case": "# Example test case\nransom_note = 'aa'\nmagazine = 'aab'\nexpected = True", |
| 42 | + "playground_execution": "result = Solution().can_construct(ransom_note, magazine)\nresult", |
| 43 | + "playground_assertion": "assert result == expected" |
| 44 | +} |
0 commit comments