0
点赞
收藏
分享

微信扫一扫

[MT8766][Android12] 增加应用安装白名单或者黑名单

言诗把酒 2023-11-11 阅读 34

Practice makes perfect!

在这里插入图片描述

实战一:
在这里插入图片描述
在这里插入图片描述

struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) {
    struct ListNode* curA=headA;
    struct ListNode* curB=headB;
    int lenA=1;
    int lenB=1;
    while(curA->next)
    {
        lenA++;
        curA=curA->next;
    }
    while(curB->next)
    {
        lenB++;
        curB=curB->next;
    }
    struct ListNode* longlist=headA;
    struct ListNode* shortlist=headB;
    int k=abs(lenA-lenB);
    if(lenA<lenB)
    {
        longlist=headB;
        shortlist=headA;
    }
    while(k--)
    {
        longlist=longlist->next;
    }
    while(longlist!=shortlist)
    {
        longlist=longlist->next;
        shortlist=shortlist->next;
    }
    return shortlist;
    
}

注意:代码中的abs是求绝对值的函数。

实战二:
在这里插入图片描述
在这里插入图片描述

struct ListNode* reverseList(struct ListNode* head) {
    if(head==NULL)
    {
        return NULL;
    }
    struct ListNode* n1,*n2,*n3;
    n1=NULL;
    n2=head;
    n3=head->next;
    while(n2)
    {
        n2->next=n1;
        n1=n2;
        n2=n3;
        if(n3)
        {
            n3=n3->next;
        }
    }
    return n1;
}

方法来源于积累,继续努力!

举报

相关推荐

0 条评论