删除链表的节点。
struct ListNode
{
int val;
ListNode* next;
ListNode(int x):val(x),next(NULL){}
};
calss Solution
{
public:
ListNode* deleteNode(ListNode* head,int val)
{
if(head->val==val) return head->next;
ListNode* p=head;
while(p->next->val!=val)
{
p=p->next;
}
p->next=p->next->next;
return head;
}
};