128工作


A.首先對於戰略進行總結——活得清楚才能活得好

1.如何快速進入狀態

遠離手機,放歌,由易到難,手眼心口同步啟動

2.做題應該怎么做

 做題以目標為導向,每天總結第二天的背誦內容

有用的網頁內容要及時計入當天的工作計划,還沒有寫完或者查驗的代碼要保留好工作現場

定時定計划,手眼心口同步

3.選題怎么選

 LeetCode入門

4.一天怎么衡量自己學的好不好

每天至少兩新一舊這個量一定要達到

定量,定規矩,定時間

5.究竟需要什么

 每天寫日記

6.怎么讀懂代碼,不被迷惑

舉例子,多觀察,再思考,再總結,再重復。

7.心理建設

想玩是正常的,但是選擇是自己的

快速動手學習是打開學習思路的最好方法

玩人喪德,玩物喪志,固執不變,是為自欺欺人

貪玩並不是你的真正心願,這是被欺騙無知少年少女的網絡劇言情劇誤導的,我希望能功成名就,日進斗金,,腰纏萬貫,有一個像都教授這樣的藏書閣

 

 

 

 

 

 

B.LeetCode

137 用先排序再比較和后面有無相同選擇是否跳過也是解決的一種普通方法,但是要注意,for循環作用就是每次經過他的時候都為變量加1。所以本題發現相同只能加2,剩下的1要由for來加

sort函數復雜度為nlogn

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int n=nums.size();
        sort(nums.begin(),nums.end());
        for(int i=0;i<n-1;i++)
        {
            if(nums[i]==nums[i+1])
            {
                //只能加2,剩下一個由for循環加
                i+=2;
            }
            else
            {
                return nums[i];
            }
        }
       return nums[n-1];
    }
};

 137

https://blog.csdn.net/qq_17550379/article/details/83926804

 138

我寫的代碼超時,正在找原因

/*
// Definition for a Node.
class Node {
public:
    int val;
    Node* next;
    Node* random;
    
    Node(int _val) {
        val = _val;
        next = NULL;
        random = NULL;
    }
};
*/
class Solution {
public:
    Node* copyRandomList(Node* head) {
     Node* store=head;
        //add part
        while(head->next)
        {
             Node* tmp=new Node(head->val);
             tmp->next=head->next;
             head->next=tmp;
             head=head->next->next;
        }
      Node* end = new Node(head->val);
      head->next=end;
      head=store;
      //deal with random pointer
      while(head->next)
      {
          if(head->random==NULL)
              head->next->random=NULL;
          else
          {
              head->next->random=head->random->next;
              head=head->next->next;
          }
        
      }
      //delete
      head=store;
      head=head->next;
      while(head->next)
      {
        head->next=head->next->next;
        head=head->next->next;
      }
  return store->next;
    }
};

修改版,雖能運行,還是有問題

/*
// Definition for a Node.
class Node {
public:
    int val;
    Node* next;
    Node* random;
    
    Node(int _val) {
        val = _val;
        next = NULL;
        random = NULL;
    }
};
*/
class Solution {
public:
    Node* copyRandomList(Node* head) {
        if(!head) return NULL;
     Node* store=head;
        //add part
        while(head)
        {
             Node* tmp=new Node(head->val);
             tmp->next=head->next;
             head->next=tmp;
             head=head->next->next;
        }
      // Node* end = new Node(head->val);
      // head->next=end;
      head=store;
      //deal with random pointer
      while(head)
      {
          if(head->random==NULL)
              head->next->random=NULL;
          else
          {
              head->next->random=head->random->next;
              
          }head=head->next->next;
        
      }
      //delete
      head=store;
      head=head->next;
      store=head;
      while(head)
      {
        head->next=head->next->next;
        head=head->next->next;
      }
  return store->next;
    }
};

報錯: 

Next pointer of node with label 7 from the original list was modified.

 

C.POJ

 

O.好網站博客

https://www.jianshu.com/p/77d0dd2fa3ee

https://www.cnblogs.com/carsonzhu/p/5375070.html

 

I.白板答題經驗:

1》括號,分號要提前寫好,對稱的符號,避免因此遺漏,class定義最后要寫冒號

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM