|
41 | 41 | solution_methods: [
|
42 | 42 | {
|
43 | 43 | name: "reverse_between", // snake_case method name
|
44 |
| - parameters: "head: ListNode | None, left: int, right: int", // Use ListNode | None for nullable parameters |
45 |
| - return_type: "ListNode | None", // Modern union syntax |
| 44 | + parameters: "head: ListNode[int] | None, left: int, right: int", // Use ListNode[int] | None for nullable parameters |
| 45 | + return_type: "ListNode[int] | None", // Modern union syntax with explicit generic type |
46 | 46 | dummy_return: "None", // None for linked list problems
|
47 | 47 | },
|
48 | 48 | ],
|
|
65 | 65 | parametrize_typed: "head_list: list[int], left: int, right: int, expected_list: list[int]",
|
66 | 66 | test_cases: "[([1, 2, 3, 4, 5], 2, 4, [1, 4, 3, 2, 5]), ([5], 1, 1, [5])]",
|
67 | 67 | // IMPORTANT: Linked list test body converts arrays to ListNode and compares objects directly
|
68 |
| - body: "head = ListNode.from_list(head_list)\nexpected = ListNode.from_list(expected_list)\nresult = self.solution.reverse_between(head, left, right)\nassert result == expected", |
| 68 | + body: "head = ListNode[int].from_list(head_list)\nexpected = ListNode[int].from_list(expected_list)\nresult = self.solution.reverse_between(head, left, right)\nassert result == expected", |
69 | 69 | },
|
70 | 70 | ],
|
71 | 71 |
|
72 | 72 | // === PLAYGROUND NOTEBOOK ===
|
73 | 73 | // IMPORTANT: Linked list playground needs ListNode import and conversion
|
74 | 74 | playground_imports: "from solution import Solution\n\nfrom leetcode_py import ListNode",
|
75 |
| - playground_test_case: "# Example test case\nhead_list = [1, 2, 3, 4, 5]\nhead = ListNode.from_list(head_list)\nleft, right = 2, 4\nexpected = ListNode.from_list([1, 4, 3, 2, 5])", |
| 75 | + playground_test_case: "# Example test case\nhead_list = [1, 2, 3, 4, 5]\nhead = ListNode[int].from_list(head_list)\nleft, right = 2, 4\nexpected = ListNode[int].from_list([1, 4, 3, 2, 5])", |
76 | 76 | playground_execution: "result = Solution().reverse_between(head, left, right)\nresult",
|
77 | 77 | playground_assertion: "assert result == expected",
|
78 | 78 | }
|
0 commit comments