欧美1区2区3区激情无套,两个女人互添下身视频在线观看,久久av无码精品人妻系列,久久精品噜噜噜成人,末发育娇小性色xxxx

《InterviewGuide》第十彈面試手撕題

說實話,算法這種東西沒得快速提升,算法能力的提升需要日積月累慢慢累積而成的。

在互聯(lián)網(wǎng)招聘中,不管是筆試還是面試中的手撕算法,可以考察的算法題簡直不要太多。比如鏈表、樹、數(shù)組、動態(tài)規(guī)劃、回溯算法、貪心算法、甚至是拓撲都有可能考察到。

而一般說來筆試的難度是比面試稍微高一些的,面試中的手撕算法難度一般是力扣的 medium 水平,也有一些 easy 的,而筆試至少都是力扣 medium 難度以上的。

我僅在這章節(jié)中為大家盤點一下互聯(lián)網(wǎng)大廠面試考察頻率比較高的幾道手撕算法題,希望我的整理對大家有一點點用處,那我就很高興了!。

1、合并有序鏈表

將兩個有序的鏈表合并為一個新鏈表,要求新的鏈表是通過拼接兩個鏈表的節(jié)點來生成的。

輸入:1->2->4, 1->3->4
輸出:1->1->2->3->4->4

力扣鏈接:https://leetcode-cn.com/problems/he-bing-liang-ge-pai-xu-de-lian-biao-lcof/

#include <iostream>
using namespace std;

struct myList {
    int val;
    myList* next;
    myList(int _val) :val(_val), next(nullptr) {}
};

myList* merge(myList* l1, myList* l2) {

    if (l1 == nullptr) return l2;
    if (l2 == nullptr) return l1;
    myList head(0);
    myList* node = &head;
    while (l1 != nullptr && l2 != nullptr) {
        if (l1->val < l2->val) {
            node->next = l1;
            l1 = l1->next;

        }
        else {
            node->next = l2;
            l2 = l2->next;
        }
        node = node->next;
    }

    if (l1 == nullptr)
        node->next = l2;
    if (l2 == nullptr)
        node->next = l1;

    return head.next;

};

int main(void) {

    myList* node0 = new myList(0);
    myList* node1 = new myList(1);
    myList* node2 = new myList(2);
    myList* node3 = new myList(3);

    myList* node4 = new myList(1);
    myList* node5 = new myList(4);
    node0->next = node1;
    node1->next = node2;
    node2->next = node3;
    node3->next = nullptr;
    node4->next = node5;
    node5->next = nullptr;

    auto node = merge(node0, node4);
    while (node != nullptr) {
        cout << node->val << endl;
        node = node->next;
    }

    return 0;
}

2、反轉(zhuǎn)鏈表

定義一個函數(shù),輸入一個鏈表的頭節(jié)點,反轉(zhuǎn)該鏈表并輸出反轉(zhuǎn)后鏈表的頭節(jié)點。

輸入: 1->2->3->4->5->NULL
輸出: 5->4->3->2->1->NULL

第一種做法

#include<algorithm>
#include<unordered_map>
#include <iostream>
#include<vector>

using namespace std;

struct node {
    int  data;
    struct node* next;
    node(int _data) :data(_data), next(nullptr) {
    }
};

struct node* init() {
    node* head = new node(1);
    node* node1 = new node(2);
    node* node2 = new node(3);
    node* node3 = new node(4);
    node* node4 = new node(5);

    head->next = node1;
    node1->next = node2;
    node2->next = node3;
    node3->next = node4;
    node4->next = nullptr;

    return head;
}

struct node* reverse(node* head) {
    struct node* pre = new node(-1);
    struct node* temp = new node(-1);
    pre = head;
    temp = head->next;
    pre->next = nullptr;    
    struct node* cur = new node(-1);
    cur = temp;
    while (cur != nullptr) {
        temp = cur;
        cur = cur->next;
        temp->next = pre;
        pre = temp;
    }

    return pre;
}

int main(){
    auto head = init();
    head = reverse(head);
    while (head != nullptr) {
        cout << head->data << endl;
        head = head->next;
    }

    return 0;
}

第二種做法

//頭插法來做,將元素開辟在棧上,這樣會避免內(nèi)存泄露
ListNode* ReverseList(ListNode* pHead) {

    // 頭插法
    if (pHead == nullptr || pHead->next == nullptr) return pHead;
    ListNode dummyNode = ListNode(0);
    ListNode* pre = &(dummyNode);
    pre->next = pHead;
    ListNode* cur = pHead->next;
    pHead->next = nullptr;
    //pre = cur;
    ListNode* temp = nullptr;
    while (cur != nullptr) {
        temp = cur;
        cur = cur->next;
        temp->next = pre->next;
        pre->next = temp;
    }
    return dummyNode.next;

}

3、單例模式

餓漢模式

class singlePattern {
private:
    singlePattern() {};
    static singlePattern* p;
public:
    static singlePattern* instance();

    class CG {
    public:
        ~CG() {
            if (singlePattern::p != nullptr) {
                delete singlePattern::p;
                singlePattern::p = nullptr;
            }
        }
    };
};

singlePattern* singlePattern::p = new singlePattern();
singlePattern* singlePattern::instance() {
    return p;
}

update1: instance 手誤寫成 instacne,微信好友“卷軸”提出,已修正,感謝!- 20210407

懶漢模式

class singlePattern {
private:
    static singlePattern* p;
    singlePattern(){}
public:
    static singlePattern* instance();
    class CG {
    public:
        ~CG() {
            if (singlePattern::p != nullptr) {
                delete singlePattern::p;
                singlePattern::p = nullptr;
            }
        }
    };
};
singlePattern* singlePattern::p = nullptr;
singlePattern* singlePattern::instance() {
    if (p == nullptr) {
        return new singlePattern();
    }
    return p;
}

4、簡單工廠模式

typedef enum productType {
    TypeA,
    TypeB,
    TypeC
} productTypeTag;

class Product {

public:
    virtual void show() = 0;
    virtual ~Product() = 0;
};

class ProductA :public Product {
public:
    void show() {
        cout << "ProductA" << endl;
    }
    ~ProductA() {
        cout << "~ProductA" << endl;
    }
};

class ProductB :public Product {
public:
    void show() {
        cout << "ProductB" << endl;
    }
    ~ProductB() {
        cout << "~ProductB" << endl;
    }
};

class ProductC :public Product {
public:
    void show() {
        cout << "ProductC" << endl;
    }
    ~ProductC() {
        cout << "~ProductC" << endl;
    }
};

class Factory {

public:
    Product* createProduct(productType type) {
        switch (type) {
        case TypeA:
            return new ProductA();
        case TypeB:
            return new ProductB();
        case TypeC:
       

剩余60%內(nèi)容,訂閱專欄后可繼續(xù)查看/也可單篇購買

????《阿秀的校招求職筆記》 文章被收錄于專欄

- 本專欄成功幫助阿秀拿到字節(jié)跳動SP的offer,脫胎于個人秋招時期的筆記總結(jié)。其中收納C++(217道)、操作系統(tǒng)(62道)、計算機網(wǎng)絡(luò)(100道)、數(shù)據(jù)結(jié)構(gòu)與算法、數(shù)據(jù)庫(MySQL、Redis)等高頻問答知識點。 - 本專欄適合于校招、社招等找工作黨,后來逐漸收錄一些學(xué)弟學(xué)妹的上岸經(jīng)驗和方法,歡迎訂閱,持續(xù)更新ing。

全部評論
想請教一下,單例模式里面的CG類是什么??
點贊 回復(fù) 分享
發(fā)布于 2021-06-14 16:14
感謝參與【創(chuàng)作者計劃2期·技術(shù)干貨場】!歡迎更多牛油來寫干貨,瓜分總計20000元獎勵??!技術(shù)干貨場活動鏈接:http://fangfengwang8.cn/link/czz2jsghtlq(參與獎馬克杯將于每周五結(jié)算,敬請期待~)
點贊 回復(fù) 分享
發(fā)布于 2021-04-14 11:51
來了阿秀
點贊 回復(fù) 分享
發(fā)布于 2021-04-09 23:16

相關(guān)推薦

入職一個多月了,來分享一些landing的感受~&nbsp;整體說下:可以打85分,畢竟當時辭職就是想要走出舒適圈,的確也會有些不舒適,但基本上是因為阿里和網(wǎng)易風格有差別,需要一些時間適應(yīng)&nbsp;我所在的產(chǎn)品線整體風格不卷,加班不嚴重,周末大家都安排自己的生活,可以安心放下手機,也讓我徹底放下“不秒回羞恥癥”&nbsp;阿里云團隊規(guī)模太大,分工很細,人也很多,想搞清楚一件事情要對接好多好多人,要熟悉的流程也賊多,這個過程的確有些累,但我估計只要在大廠都會這樣&nbsp;感覺這邊做事情自由度更高,換句話說,老板只要結(jié)果,過程怎么做自己想辦法去&nbsp;凡事凡人都愛講價值。初次對接的其他部門的同事,也會直接問我,“你對業(yè)務(wù)的價值是什么”&nbsp;前線上線下接觸到的同事估計有四五十個,99%交流都順暢,有話都直說&nbsp;一個月約了不少coffee&nbsp;talk,即使沒有直接的工作關(guān)聯(lián),大家還都挺熱心解答我各種疑惑,很開心&nbsp;和+1&nbsp;溝通很順暢,一是我剛?cè)肼毦秃退_認了溝通風格,二是我會主動表達自己的一些困惑,尋求幫助。當我不知道怎么和其他團隊TL&nbsp;開展協(xié)同的時候,她也會幫我絲滑落地&nbsp;另外有幾個我?guī)熜纸o的tips:&nbsp;?拋開對情緒的關(guān)注,過分關(guān)注對方是老員工or說了句什么重話or質(zhì)疑了什么,就沒法協(xié)作了&nbsp;?即使不喜歡,在該刷存在感的時候也得刷&nbsp;?等過了前半年蜜月期,也許你也會感到工作很痛苦&nbsp;新環(huán)境讓我的狀態(tài)好了很多,或許是因為還在蜜月期,or團隊的風格,or只是還沒接觸到那么多人和事兒,我也不確定從多久后開始,我也會感到煩躁、痛苦。&nbsp;那,既然不知道,當然是能快樂一天是一天啦~&nbsp;還有就是,我相信這一次的轉(zhuǎn)變,我個人在心境上的調(diào)整和成長也起到了很大的作用。&nbsp;無論世界怎樣,把情緒掌握在自己手中。阿里云2026屆可轉(zhuǎn)正實習(xí)生招聘正式開啟!【公司介紹】阿里云是全球領(lǐng)先的云計算及人工智能科技公司,堅持讓計算成為公共服務(wù),助力全球客戶加速價值創(chuàng)新。【招聘崗位】技術(shù)類、運營類、設(shè)計類、營銷類、產(chǎn)品類、內(nèi)容類、職能類等(每位同學(xué)僅有1次投遞機會,2個意向)【工作地點】杭州、北京、上海、深圳、成都等城市【面向人群】海內(nèi)外院校2026屆畢業(yè)生,畢業(yè)時間在2025年11月-2026年10月內(nèi)【內(nèi)推步驟】點擊「內(nèi)推鏈接」開啟內(nèi)推-&amp;amp;gt;查看內(nèi)推職位/部門-&amp;amp;gt;提交個人信息-&amp;amp;gt;點擊郵件內(nèi)鏈接確認接受內(nèi)推,補充意向并完善簡歷-&amp;amp;gt;內(nèi)推成功??內(nèi)推一鍵投遞:https://careers.aliyun.com/campus/qrcode/apply/positions?code=yzYD/K3PP/D42kc4e1WhOePAeAX7co5ZGo9MaGDwhhQ=&nbsp;&nbsp;&nbsp;&nbsp;(內(nèi)推簡歷優(yōu)先篩選,后續(xù)有疑問/流程問題歡迎聯(lián)系)使用內(nèi)推碼簡歷優(yōu)先篩選,有任何問題包括進度查詢可以私信我,內(nèi)推后在評論區(qū)留言【姓名縮寫+崗位】,方便撈人和確認投遞狀態(tài) #春招#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#內(nèi)推#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#內(nèi)推碼#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#阿里云#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
點贊 評論 收藏
分享
評論
3
10
分享

創(chuàng)作者周榜

更多
??途W(wǎng)
??推髽I(yè)服務(wù)