[关闭]
@snuffles 2015-04-05T10:32:34.000000Z 字数 550 阅读 1001

Partition List

leetcode


20150405
1.initialization from incompatible pointer type
2.指针的用法
3.改用C实现
use this code to ac
the learning point of this problem to read

  1. /**
  2. * Definition for singly-linked list.
  3. * struct ListNode {
  4. * int val;
  5. * struct ListNode *next;
  6. * };
  7. */
  8. struct ListNode *partition(struct ListNode *head, int x)
  9. {
  10. struct Listnode *small=head;
  11. struct Listnode *big=head;
  12. struct Listnode *key=head;
  13. for(;key!=NULL;key=key->next){
  14. if(key->val<x){
  15. small->val=key->val;
  16. small=key->next;
  17. }
  18. }
  19. big=small->next=big;
  20. key=head;
  21. for(;key!=NULL;key=key->next){
  22. if(key->val>=x){
  23. big->val=key->val;
  24. big=key->next;
  25. }
  26. }
  27. return head;
  28. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注