Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Delete Node at a given position in a linked list
- Node is defined as
- struct Node
- {
- int data;
- struct Node *next;
- }
- */
- Node* Delete(Node *head, int position)
- {
- // Complete this method
- Node *temp = head;
- if(position == 0){
- head = head->next;
- return head;
- }
- Node *temp2 = head;
- for(int i = 0 ; i < position-1; i++){
- temp2 = temp2->next;
- }
- temp = temp2->next->next;
- temp2->next = temp;
- return head;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement