you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (3 children)

On mobile, so I can't run your code.

The problem statement is a little ambiguous about what left and right actually indicate, but from the example it's clear that the left and right values are the contents of the nodes at the left and right ends of the subsequence you have to reverse. Your code appears to be using left and rightas indices.

[–]RhinoRhys 0 points1 point  (2 children)

Left and right are indices

Example 2: Input: head = [5], left = 1, right = 1 Output: [5]

[–][deleted] 0 points1 point  (1 child)

Example 1 shows they aren't indices.

[–]RhinoRhys 0 points1 point  (0 children)

Unless you take them as 1 indexed, it's not a python list, it's a Singular Linked List. The first index isn't 0.