Created
March 24, 2017 22:35
-
-
Save lichray/e438842297969f8e401b234832ce6844 to your computer and use it in GitHub Desktop.
"Two star programming" with no star
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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