Insert Node at Head Intuition: Create a new node, point it to the current head, and update the head. Node* insertAtHead(Node* head, int val) { Node* newNode = new Node(val); newNode->next = head; return newNode; } // TC: O(1) // SC: O(1) ...
No responses yet.