Python Logic of ListNode in Leetcode
The short answer to this is that, Python is a pass-by-object-reference language, not pass-by-reference as implied in the question. It means that: result and result_tail are two variables that happen to point at the same value Mutation / Changing of the underlying value (result_tail.next = ListNode(1)) will affect the value shown by result However, assigning / pointing the variable result_tail to … Read more