Could not implement erase method

Can you please give the code to implement the erase function which is given as HW at the end of this video.

void erase(string key){
		int idx=hashfun(key);
		Node<T>*temp=table[idx];
		Node<T>*prev=NULL;
		while(temp){
			if(temp->key==key){
				if(prev)prev->next=temp->next;
				else table[idx]=temp->next;
				temp->next=NULL;
				delete temp;
			}
			prev=temp;
			temp=temp->next;
		}
	}

steps

  1. find the hasvalue corresponding to given key
  2. find the node which we have to delete and then delete that node
    to delete node you also need prev pointer (linked list Deletion concept)

it is quiet simple
i hope you understood this
if not feel free to ask