Skip to content

Commit

Permalink
提交修改
Browse files Browse the repository at this point in the history
  • Loading branch information
zouxiaobo committed Apr 25, 2020
1 parent 49ed4e4 commit 9ee418e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LeetCode/刷题经验.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,26 @@ vector<int>dp(n,0);
m*n的二维数组初始化为0
vector<vector<int> >dp(m, vector<int>(0,n));

解法:for循环。设置初始值,然后开始迭代


## 回溯法(dfs)
解法:递归。通过画树,有助于写出递归代码



## 链表
1. 链表题,在涉及删除节点时,可自行在头结点前加一个节点指向头结点,这样就不用单独对头结点进行特殊处理了。实际上链表题,一般都会这么操作,可将头结点一般化。








## NOTICE
1. stack为空时,不能访问top
2. 碰到完全没思路的题,首先考虑暴力法,事实上,暴力法是任何题都可考虑的一种方法
3. 数组题,特别注意访问越界问题

34 changes: 34 additions & 0 deletions practice.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 懒汉式
class CSingleton
{
public:
CSingleton* getInstance()
{
if(m_pInstance == NULL)
m_pInstance=new CSingleton();

return m_pInstance;
}

private:
CSingleton();
static CSingleton* m_pInstance;

};

// 饿汉式
class CSingleton
{
public:
CSingleton* getInstance()
{
return m_pInstance;
}

private:
CSingleton();
static CSingleton* m_pInstance;

};

CSingleton* CSingleton::m_pInstance=new CSingleton();

0 comments on commit 9ee418e

Please sign in to comment.