【2023秋招】诗悦网络开发岗笔试AK

18min交卷,笔试一共60min,2道编程题*20 + 10道单选题*6 = 总分100分 

笔试的题都很基础,文本框作答,ACM模式和核心代码模式随意,随意写了下(其实像这种典中点的题大家再也熟悉不过了,感觉诗悦可能也是偏向于学历厂,笔试没太大筛选作用

T1- 删除链表重复节点

class Solution{
    public:
    ListNode* deleteDuplicates(ListNode * head)
    {
        if(!head || !head->next) return head;
        head->next = deleteDuplicates(head->next);
        return (head->val == head->next->val)?head->next:head;
    }
};

T2- 反转链表

#include <iostream>
using namespace std;
struct ListNode {
    int val;
    struct ListNode *next;
};
 
ListNode* reverseList(ListNode* head)
{
    ListNode *pre = NULL;
    ListNode *cur = head;
    ListNode *nex = NULL;
 
    while(cur)
    {
        nex = cur->next;
        cur->next = pre;
        pre = cur;
        cur = nex;
    }
    return pre;
}

int main()
{
    // ...
    return 0;
}

猜你喜欢

转载自blog.csdn.net/Luoxiaobaia/article/details/126801156