// removes all those nodes from the linked list which contain the integer n

void List::removeAll (int n) {

	// Here is the tricky case that I mentioned about in the class
	// First you have to remove all the occurances of the integer n
	// from the beginning of the list

	while (head != NULL && head->item == n) {
		Node* temp = head;
		head = head->next;
		delete temp;
	}


	// traverse the rest of the list to remove all the remaining
	// occurances of the integer n from the list. Here you will need
	// two pointer, prev and curr

	Node *prev = NULL;
	Node *cur = head;

	while (cur != NULL) {
		
		if (cur->item == n)  {
			// delete the node and advance the pointers
			prev->next = cur->next;
			delete cur;
			cur = prev->next;
		}
		else {
			// merely advance the pointers
			prev = cur;
			cur = cur->next;
		}
	}
}