128工作

A.首先对于战略进行总结——活得清楚才能活得好

1.如何快速进入状态

远离手机,放歌,由易到难,手眼心口同步启动

2.做题应该怎么做

 做题以目标为导向,每天总结第二天的背诵内容

有用的网页内容要及时计入当天的工作计划,还没有写完或者查验的代码要保留好工作现场

定时定计划,手眼心口同步

3.选题怎么选

 LeetCode入门

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

每天至少两新一旧这个量一定要达到

扫描二维码关注公众号,回复: 8912282 查看本文章

定量,定规矩,定时间

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定义最后要写冒号

猜你喜欢

转载自www.cnblogs.com/Marigolci/p/12239230.html
128