we can delete the element in O(1) time complexity by using the copying element method.
suppose, the elements in the linked list are 1->2->3->4. The node to be deleted is 3(denoted by X). let's take the temp pointer which points to the node just after the node is to be deleted(which means X points to node 3 and temp points to node 4). Now follow the below procedure:-
temp=X->next; (making temp to point node 4)
X->data=temp->data;
X->next=temp->next;
free(temp);
This procedure takes only O(1) time to delete any node except the last node.
finally, time complexity=O(1) and space complexity=O(1)