|
1 | 1 | {
|
2 |
| - // Linked list problem template |
3 |
| - // Use this for problems involving ListNode structures |
4 |
| - |
5 |
| - // REQUIRED: Core identifiers |
6 |
| - "problem_name": "reverse_linked_list_ii", |
7 |
| - "class_name": "ReverseLinkedListII", |
8 |
| - "method_name": "reverse_between", |
9 |
| - |
10 |
| - // REQUIRED: Problem metadata |
11 |
| - "problem_number": "92", |
12 |
| - "problem_title": "Reverse Linked List II", |
13 |
| - "difficulty": "Medium", |
14 |
| - "topics": "Linked List", |
15 |
| - |
16 |
| - // OPTIONAL: Problem categorization |
17 |
| - "tags": [], |
18 |
| - |
19 |
| - // REQUIRED: Problem description |
20 |
| - "problem_description": "Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return the reversed list.", |
21 |
| - |
22 |
| - // REQUIRED: Examples |
23 |
| - "examples": [ |
24 |
| - { "input": "head = [1,2,3,4,5], left = 2, right = 4", "output": "[1,4,3,2,5]" }, |
25 |
| - { "input": "head = [5], left = 1, right = 1", "output": "[5]" } |
26 |
| - ], |
27 |
| - |
28 |
| - // REQUIRED: Constraints |
29 |
| - "constraints": "- The number of nodes in the list is n.\n- 1 <= n <= 500\n- -500 <= Node.val <= 500\n- 1 <= left <= right <= n", |
30 |
| - |
31 |
| - // REQUIRED: Method signature |
32 |
| - "parameters": "head: ListNode | None, left: int, right: int", |
33 |
| - "return_type": "ListNode | None", |
34 |
| - "dummy_return": "None", |
35 |
| - |
36 |
| - // REQUIRED: ListNode import for linked list problems |
37 |
| - "imports": "from leetcode_py.list_node import ListNode", |
38 |
| - |
39 |
| - // REQUIRED: Test cases |
40 |
| - "test_cases": [ |
41 |
| - { "args": [[1, 2, 3, 4, 5], 2, 4], "expected": [1, 4, 3, 2, 5] }, |
42 |
| - { "args": [[5], 1, 1], "expected": [5] }, |
43 |
| - { "args": [[1, 2, 3], 1, 3], "expected": [3, 2, 1] } |
44 |
| - ], |
45 |
| - |
46 |
| - // REQUIRED: Test parameters (use expected_list for linked list problems) |
47 |
| - "param_names": "head_list, left, right, expected_list", |
48 |
| - "param_names_with_types": "head_list: list[int], left: int, right: int, expected_list: list[int]", |
49 |
| - "input_description": "head_list={head_list}, left={left}, right={right}", |
50 |
| - "input_params": "head, left, right", |
51 |
| - "expected_param": "expected", |
52 |
| - "method_args": "head, left, right", |
53 |
| - |
54 |
| - // REQUIRED: Linked list-specific test setup |
55 |
| - "test_setup": "head = ListNode.from_list(head_list)\nexpected = ListNode.from_list(expected_list)", |
56 |
| - "test_logging": "logger.success(f\"Got result: {result.to_list() if result else []}\")", |
57 |
| - "assertion_code": "assert result == expected", |
58 |
| - |
59 |
| - // REQUIRED: Notebook setup for linked list problems |
60 |
| - "test_input_setup": "# Example test case\nhead = ListNode.from_list([1, 2, 3, 4, 5])\nleft = 2\nright = 4", |
61 |
| - "expected_output_setup": "expected = ListNode.from_list([1, 4, 3, 2, 5])" |
| 2 | + // Linked list problem template |
| 3 | + // Use this for problems involving ListNode structures |
| 4 | + |
| 5 | + // REQUIRED: Core identifiers |
| 6 | + problem_name: "reverse_linked_list_ii", |
| 7 | + class_name: "ReverseLinkedListII", |
| 8 | + method_name: "reverse_between", |
| 9 | + |
| 10 | + // REQUIRED: Problem metadata |
| 11 | + problem_number: "92", // OPTIONAL: omit if no LeetCode number |
| 12 | + problem_title: "Reverse Linked List II", |
| 13 | + difficulty: "Medium", |
| 14 | + topics: "Linked List", |
| 15 | + |
| 16 | + // OPTIONAL: Problem categorization |
| 17 | + tags: [], |
| 18 | + |
| 19 | + // REQUIRED: Problem description |
| 20 | + problem_description: "Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return the reversed list.", |
| 21 | + |
| 22 | + // REQUIRED: Examples |
| 23 | + examples: [ |
| 24 | + { input: "head = [1,2,3,4,5], left = 2, right = 4", output: "[1,4,3,2,5]" }, |
| 25 | + { input: "head = [5], left = 1, right = 1", output: "[5]" }, |
| 26 | + ], |
| 27 | + |
| 28 | + // REQUIRED: Constraints |
| 29 | + constraints: "- The number of nodes in the list is n.\n- 1 <= n <= 500\n- -500 <= Node.val <= 500\n- 1 <= left <= right <= n", |
| 30 | + |
| 31 | + // REQUIRED: Method signature |
| 32 | + parameters: "head: ListNode | None, left: int, right: int", |
| 33 | + return_type: "ListNode | None", |
| 34 | + dummy_return: "None", |
| 35 | + |
| 36 | + // REQUIRED: ListNode import for linked list problems |
| 37 | + imports: "from leetcode_py import ListNode", |
| 38 | + |
| 39 | + // REQUIRED: Test cases |
| 40 | + test_cases: [ |
| 41 | + { args: [[1, 2, 3, 4, 5], 2, 4], expected: [1, 4, 3, 2, 5] }, |
| 42 | + { args: [[5], 1, 1], expected: [5] }, |
| 43 | + { args: [[1, 2, 3], 1, 3], expected: [3, 2, 1] }, |
| 44 | + ], |
| 45 | + |
| 46 | + // REQUIRED: Test parameters (use expected_list for linked list problems) |
| 47 | + param_names: "head_list, left, right, expected_list", |
| 48 | + param_names_with_types: "head_list: list[int], left: int, right: int, expected_list: list[int]", |
| 49 | + input_description: "head_list={head_list}, left={left}, right={right}", |
| 50 | + input_params: "head, left, right", |
| 51 | + expected_param: "expected", |
| 52 | + method_args: "head, left, right", |
| 53 | + |
| 54 | + // REQUIRED: Linked list-specific test setup |
| 55 | + test_setup: "head = ListNode.from_list(head_list)\nexpected = ListNode.from_list(expected_list)", |
| 56 | + test_logging: 'logger.success(f"Got result: {result.to_list() if result else []}")', |
| 57 | + assertion_code: "assert result == expected", |
| 58 | + |
| 59 | + // REQUIRED: Notebook setup for linked list problems |
| 60 | + test_input_setup: "# Example test case\nhead = ListNode.from_list([1, 2, 3, 4, 5])\nleft = 2\nright = 4", |
| 61 | + expected_output_setup: "expected = ListNode.from_list([1, 4, 3, 2, 5])", |
62 | 62 | }
|
0 commit comments