棧
stack<char> stack;
stack.top();
stack.push(num);
LeetCode 20 有效的括號

image.png
LeetCode 71 簡化路徑(練習(xí))

image.png

image.png
LeetCode 144 二叉樹前序遍歷
LeetCode 94 二叉樹中序遍歷(練習(xí))
LeetCode 145 二叉樹后序遍歷(練習(xí))
LeetCode 341 扁平化嵌套列表迭代器(練習(xí))

image.png
隊(duì)列
queue<pair<TreeNode,int>> q;
q.push(make_pair(root,0));
TreeNode node = q.front().first;
int level = q.front().second;
LeetCode 102 二叉樹的層序遍歷

image.png
LeetCode 107 二叉樹的層序遍歷II(練習(xí))

image.png
LeetCode 103 二叉樹鋸齒型層序遍歷(練習(xí))

image.png
LeetCode 199 二叉樹的右視圖(練習(xí))

image.png
LeetCode 279 完全平方數(shù)

image.png
LeetCode 127 單詞接龍(練習(xí))

image.png

image.png
LeetCode 126 單詞接龍II(練習(xí))

image.png

image.png
優(yōu)先隊(duì)列,底層實(shí)現(xiàn):堆。默認(rèn)最大堆
最大堆:priority_queue<int> pq;
pq.push(num)
pq.top()
最小堆: priority_queue<int, vector<int>, greater<int>> pq;
自定義比較函數(shù):priority_queue<int, vector<int>, function<bool(int,int)>> pq(myCmp);
bool myCmp(int a , int b){
return a%10 < b%10;
}
需要學(xué)習(xí)一下堆的底層實(shí)現(xiàn),有些公司會考堆的白板編程
LeetCode 347 前k個高頻元素, 方法優(yōu)先隊(duì)列

image.png

image.png

image.png
LeetCode 23 合并k個升序鏈表(練習(xí))

image.png