class Solution {
public:
ListNode* removeElements(ListNode* head, int val) {
/*while (head == NULL){
return head;
}
No need for this funtion since we gotta return head in the end of the funtion anyways so this case wud be included
*/
while (head != NULL && head -> val == val){
head = head -> next;
}
ListNode* curr = head;
while (curr != NULL && curr -> next != NULL){
if (curr -> next -> val == val){
curr -> next = curr -> next -> next;
}
else {
curr = curr -> next;
}
}
return head;
}
};