We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
TIP101 Unit 5 Session 2 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
new_node
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Modify the linked list by inserting a new node at the beginning and updating the head of the list to this new node.
1) Set the `next` attribute of the `new_node` to the current `head` of the linked list. 2) Return `new_node`, as it is now the new head of the list.
⚠️ Common Mistakes
head
next
def add_first(head, new_node): new_node.next = head return new_node