Skip to content

Instantly share code, notes, and snippets.

@lichray lichray/203.cc
Created Mar 24, 2017

Embed
What would you like to do?
"Two star programming" with no star
#include <functional>
class Solution {
public:
ListNode* removeElements(ListNode* head, int val) {
auto ls = std::ref(head);
while (ls != nullptr) {
if (ls.get()->val == val) {
auto p = ls.get();
ls.get() = p->next;
delete p;
}
else
ls = ls.get()->next;
}
return head;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.