# -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Remove: def removeNode(self, pNode): # write code here if pNode.next==None: return False else: pNode.val=pNode.next.val pNode.next=pNode.next.next return True
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) {} };*/ class Remove { public: bool removeNode(ListNode* pNode) { // write code here if((pNode->next==NULL && pNode!=NULL)|| pNode==NULL) return false; else{ pNode->val=pNode->next->val; pNode->next=pNode->next->next; return true; } } };