|
22 | 22 | "name": "stdout", |
23 | 23 | "output_type": "stream", |
24 | 24 | "text": [ |
25 | | - "Original: [1, 2, 3, 4, 5]\n", |
26 | | - "Expected: [5, 4, 3, 2, 1]\n" |
| 25 | + "Original: 1 -> 2 -> 3 -> 4 -> 5\n", |
| 26 | + "Expected: 5 -> 4 -> 3 -> 2 -> 1\n" |
27 | 27 | ] |
28 | 28 | } |
29 | 29 | ], |
|
41 | 41 | }, |
42 | 42 | { |
43 | 43 | "cell_type": "code", |
44 | | - "execution_count": null, |
| 44 | + "execution_count": 3, |
45 | 45 | "id": "execute", |
46 | 46 | "metadata": {}, |
47 | 47 | "outputs": [ |
48 | 48 | { |
49 | 49 | "name": "stdout", |
50 | 50 | "output_type": "stream", |
51 | 51 | "text": [ |
52 | | - "Result: [5, 4, 3, 2, 1]\n" |
| 52 | + "Result: 5 -> 4 -> 3 -> 2 -> 1\n" |
53 | 53 | ] |
54 | 54 | }, |
55 | 55 | { |
56 | 56 | "data": { |
| 57 | + "text/html": [ |
| 58 | + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n", |
| 59 | + "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n", |
| 60 | + " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n", |
| 61 | + "<!-- Generated by graphviz version 13.1.2 (20250808.2320)\n", |
| 62 | + " -->\n", |
| 63 | + "<!-- Pages: 1 -->\n", |
| 64 | + "<svg width=\"422pt\" height=\"44pt\"\n", |
| 65 | + " viewBox=\"0.00 0.00 422.00 44.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", |
| 66 | + "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 40)\">\n", |
| 67 | + "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-40 418,-40 418,4 -4,4\"/>\n", |
| 68 | + "<!-- node_0 -->\n", |
| 69 | + "<g id=\"node1\" class=\"node\">\n", |
| 70 | + "<title>node_0</title>\n", |
| 71 | + "<path fill=\"lightblue\" stroke=\"black\" d=\"M42,-36C42,-36 12,-36 12,-36 6,-36 0,-30 0,-24 0,-24 0,-12 0,-12 0,-6 6,0 12,0 12,0 42,0 42,0 48,0 54,-6 54,-12 54,-12 54,-24 54,-24 54,-30 48,-36 42,-36\"/>\n", |
| 72 | + "<text xml:space=\"preserve\" text-anchor=\"middle\" x=\"27\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">5</text>\n", |
| 73 | + "</g>\n", |
| 74 | + "<!-- node_1 -->\n", |
| 75 | + "<g id=\"node2\" class=\"node\">\n", |
| 76 | + "<title>node_1</title>\n", |
| 77 | + "<path fill=\"lightblue\" stroke=\"black\" d=\"M132,-36C132,-36 102,-36 102,-36 96,-36 90,-30 90,-24 90,-24 90,-12 90,-12 90,-6 96,0 102,0 102,0 132,0 132,0 138,0 144,-6 144,-12 144,-12 144,-24 144,-24 144,-30 138,-36 132,-36\"/>\n", |
| 78 | + "<text xml:space=\"preserve\" text-anchor=\"middle\" x=\"117\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">4</text>\n", |
| 79 | + "</g>\n", |
| 80 | + "<!-- node_0->node_1 -->\n", |
| 81 | + "<g id=\"edge1\" class=\"edge\">\n", |
| 82 | + "<title>node_0->node_1</title>\n", |
| 83 | + "<path fill=\"none\" stroke=\"black\" d=\"M54.4,-18C61.89,-18 70.18,-18 78.2,-18\"/>\n", |
| 84 | + "<polygon fill=\"black\" stroke=\"black\" points=\"78.1,-21.5 88.1,-18 78.1,-14.5 78.1,-21.5\"/>\n", |
| 85 | + "</g>\n", |
| 86 | + "<!-- node_2 -->\n", |
| 87 | + "<g id=\"node3\" class=\"node\">\n", |
| 88 | + "<title>node_2</title>\n", |
| 89 | + "<path fill=\"lightblue\" stroke=\"black\" d=\"M222,-36C222,-36 192,-36 192,-36 186,-36 180,-30 180,-24 180,-24 180,-12 180,-12 180,-6 186,0 192,0 192,0 222,0 222,0 228,0 234,-6 234,-12 234,-12 234,-24 234,-24 234,-30 228,-36 222,-36\"/>\n", |
| 90 | + "<text xml:space=\"preserve\" text-anchor=\"middle\" x=\"207\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">3</text>\n", |
| 91 | + "</g>\n", |
| 92 | + "<!-- node_1->node_2 -->\n", |
| 93 | + "<g id=\"edge2\" class=\"edge\">\n", |
| 94 | + "<title>node_1->node_2</title>\n", |
| 95 | + "<path fill=\"none\" stroke=\"black\" d=\"M144.4,-18C151.89,-18 160.18,-18 168.2,-18\"/>\n", |
| 96 | + "<polygon fill=\"black\" stroke=\"black\" points=\"168.1,-21.5 178.1,-18 168.1,-14.5 168.1,-21.5\"/>\n", |
| 97 | + "</g>\n", |
| 98 | + "<!-- node_3 -->\n", |
| 99 | + "<g id=\"node4\" class=\"node\">\n", |
| 100 | + "<title>node_3</title>\n", |
| 101 | + "<path fill=\"lightblue\" stroke=\"black\" d=\"M312,-36C312,-36 282,-36 282,-36 276,-36 270,-30 270,-24 270,-24 270,-12 270,-12 270,-6 276,0 282,0 282,0 312,0 312,0 318,0 324,-6 324,-12 324,-12 324,-24 324,-24 324,-30 318,-36 312,-36\"/>\n", |
| 102 | + "<text xml:space=\"preserve\" text-anchor=\"middle\" x=\"297\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">2</text>\n", |
| 103 | + "</g>\n", |
| 104 | + "<!-- node_2->node_3 -->\n", |
| 105 | + "<g id=\"edge3\" class=\"edge\">\n", |
| 106 | + "<title>node_2->node_3</title>\n", |
| 107 | + "<path fill=\"none\" stroke=\"black\" d=\"M234.4,-18C241.89,-18 250.18,-18 258.2,-18\"/>\n", |
| 108 | + "<polygon fill=\"black\" stroke=\"black\" points=\"258.1,-21.5 268.1,-18 258.1,-14.5 258.1,-21.5\"/>\n", |
| 109 | + "</g>\n", |
| 110 | + "<!-- node_4 -->\n", |
| 111 | + "<g id=\"node5\" class=\"node\">\n", |
| 112 | + "<title>node_4</title>\n", |
| 113 | + "<path fill=\"lightblue\" stroke=\"black\" d=\"M402,-36C402,-36 372,-36 372,-36 366,-36 360,-30 360,-24 360,-24 360,-12 360,-12 360,-6 366,0 372,0 372,0 402,0 402,0 408,0 414,-6 414,-12 414,-12 414,-24 414,-24 414,-30 408,-36 402,-36\"/>\n", |
| 114 | + "<text xml:space=\"preserve\" text-anchor=\"middle\" x=\"387\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">1</text>\n", |
| 115 | + "</g>\n", |
| 116 | + "<!-- node_3->node_4 -->\n", |
| 117 | + "<g id=\"edge4\" class=\"edge\">\n", |
| 118 | + "<title>node_3->node_4</title>\n", |
| 119 | + "<path fill=\"none\" stroke=\"black\" d=\"M324.4,-18C331.89,-18 340.18,-18 348.2,-18\"/>\n", |
| 120 | + "<polygon fill=\"black\" stroke=\"black\" points=\"348.1,-21.5 358.1,-18 348.1,-14.5 348.1,-21.5\"/>\n", |
| 121 | + "</g>\n", |
| 122 | + "</g>\n", |
| 123 | + "</svg>\n" |
| 124 | + ], |
57 | 125 | "text/plain": [ |
58 | | - "[5, 4, 3, 2, 1]" |
| 126 | + "ListNode([5, 4, 3, 2, 1])" |
59 | 127 | ] |
60 | 128 | }, |
61 | 129 | "execution_count": 3, |
|
75 | 143 | "execution_count": 4, |
76 | 144 | "id": "test", |
77 | 145 | "metadata": {}, |
78 | | - "outputs": [ |
79 | | - { |
80 | | - "name": "stdout", |
81 | | - "output_type": "stream", |
82 | | - "text": [ |
83 | | - "✅ Test passed! Linked list successfully reversed.\n" |
84 | | - ] |
85 | | - } |
86 | | - ], |
| 146 | + "outputs": [], |
87 | 147 | "source": [ |
88 | 148 | "# Verify the result matches expected output\n", |
89 | 149 | "assert result == expected" |
|
0 commit comments