class Solution {
public:
ListNode* reverseList(ListNode* head) {
ListNode *newhead=NULL;
while(head)
{
ListNode *next = head->next;
head->next = newhead;
newhead = head;
head=next;
}
return newhead;
}
};