class Solution {
public:
    ListNode*removeElements(ListNode* h, int v) {
        return h&&(h->next=removeElements(h->next,v),h->val==v)?h->next:h;
    }
};

极简递归代码