zoukankan      html  css  js  c++  java
  • 【leetcode】143. 重排链表

    void reorderList(struct ListNode* head){
        struct ListNode* arr[40000];
        struct ListNode* temp=(struct ListNode*)calloc(1,sizeof(struct ListNode));
        int pst=0;
        while(head){
            arr[pst++]=head;
            head=head->next;
        }
        for (int i=0; i<(pst+1)/2; i++){
            arr[i]->next=arr[pst-1-i];
            temp->next=arr[i];
            temp=arr[pst-1-i];
        }
        temp->next=NULL;
        return head;
    }
    void reorderList(struct ListNode* head){
        struct ListNode* arr[40000];
        struct ListNode* temp=(struct ListNode*)calloc(1,sizeof(struct ListNode));
        int pst=0;
        while(head){
            arr[pst++]=head;
            head=head->next;
        }
        for (int i=0; i<(pst+1)/2; i++){
            arr[i]->next=arr[pst-1-i];
            temp->next=arr[i];
            temp=arr[pst-1-i];
        }
        temp->next=NULL;
        return head;
    }
  • 相关阅读:
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    netty中Pipeline的ChannelHandler执行顺序案例详解
    Pi-设置无线
    Pi1-Centos
    gitlab升级
    ansible
    我也玩Jenkins
  • 原文地址:https://www.cnblogs.com/ganxiang/p/14173748.html
Copyright © 2011-2022 走看看