此题的巧妙之处在于题目数据非常大只能在原链表中解决,遇到进一的问题如果尽早判断就不会有问题,而且第一位的判断非常巧妙
struct ListNode* doubleIt(struct ListNode* head){
struct ListNode* Node = (struct ListNode*)malloc(sizeof(struct ListNode));
struct ListNode* cur = head;
if (head->val > 4) {
Node->val = 1;
Node->next = head;
head = Node;
cur = head->next;
}
while (cur != NULL) {
cur->val = cur->val*2%10;
if (cur->next && cur->next->val > 4)
cur->val++;
cur = cur->next;
}
return head;
}