|
| 1 | +{ |
| 2 | + "problem_name": "contains_duplicate", |
| 3 | + "solution_class_name": "Solution", |
| 4 | + "problem_number": "217", |
| 5 | + "problem_title": "Contains Duplicate", |
| 6 | + "difficulty": "Easy", |
| 7 | + "topics": "Array, Hash Table, Sorting", |
| 8 | + "tags": ["grind-75"], |
| 9 | + "readme_description": "Given an integer array `nums`, return `true` if any value appears **at least twice** in the array, and return `false` if every element is distinct.", |
| 10 | + "readme_examples": [ |
| 11 | + { |
| 12 | + "content": "```\nInput: nums = [1,2,3,1]\nOutput: true\n```\n**Explanation:** The element 1 occurs at the indices 0 and 3." |
| 13 | + }, |
| 14 | + { |
| 15 | + "content": "```\nInput: nums = [1,2,3,4]\nOutput: false\n```\n**Explanation:** All elements are distinct." |
| 16 | + }, |
| 17 | + { "content": "```\nInput: nums = [1,1,1,3,3,4,3,2,4,2]\nOutput: true\n```" } |
| 18 | + ], |
| 19 | + "readme_constraints": "- 1 <= nums.length <= 10^5\n- -10^9 <= nums[i] <= 10^9", |
| 20 | + "readme_additional": "", |
| 21 | + "solution_imports": "", |
| 22 | + "solution_methods": [ |
| 23 | + { |
| 24 | + "name": "contains_duplicate", |
| 25 | + "parameters": "nums: list[int]", |
| 26 | + "return_type": "bool", |
| 27 | + "dummy_return": "False" |
| 28 | + } |
| 29 | + ], |
| 30 | + "test_imports": "import pytest\nfrom leetcode_py.test_utils import logged_test\nfrom .solution import Solution", |
| 31 | + "test_class_name": "ContainsDuplicate", |
| 32 | + "test_helper_methods": [ |
| 33 | + { "name": "setup_method", "parameters": "", "body": "self.solution = Solution()" } |
| 34 | + ], |
| 35 | + "test_methods": [ |
| 36 | + { |
| 37 | + "name": "test_contains_duplicate", |
| 38 | + "parametrize": "nums, expected", |
| 39 | + "parametrize_typed": "nums: list[int], expected: bool", |
| 40 | + "test_cases": "[([1, 2, 3, 1], True), ([1, 2, 3, 4], False), ([1, 1, 1, 3, 3, 4, 3, 2, 4, 2], True)]", |
| 41 | + "body": "result = self.solution.contains_duplicate(nums)\nassert result == expected" |
| 42 | + } |
| 43 | + ], |
| 44 | + "playground_imports": "from solution import Solution", |
| 45 | + "playground_test_case": "# Example test case\nnums = [1, 2, 3, 1]\nexpected = True", |
| 46 | + "playground_execution": "result = Solution().contains_duplicate(nums)\nresult", |
| 47 | + "playground_assertion": "assert result == expected" |
| 48 | +} |
0 commit comments