/* struct ListNode {int val;struct ListNode *next;ListNode(int x) : val(x), next(NULL) {}};*/class Partition {public:ListNode* partition(ListNode* pHead, int x){// write code hereListNode* newhead=pHead,*tail=NULL,*head=NULL;ListNode* less=NULL,*greater=NULL;while(newhead){if(newhead->val<x){if(less==NULL){less=tail=newhead;}tail->next=newhead;tail=newhead;}else{if(greater==NULL){greater=head=newhead;}head->next=newhead;head=newhead;}newhead=newhead->next;}tail->next=greater;head->next=NULL;return less;}};