算法题练习
题目
栈
数学题 暴力 用别的不方便
leetcode42:接雨水 https://leetcode.cn/problems/trapping-rain-water/
链表
反转链表|offer24|0901
https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/submissions/
题解 :看图,记住初始设置,以及变化过程:https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/solution/fan-zhuan-lian-biao-yi-dong-de-shuang-zhi-zhen-jia/
删除倒数k个节点 双指针|offer19|0329
队列
滑动窗口
pre:调用【哈希集合】来判断是否有重复元素
Leetcode3
思路:遍历字符串,每一回合获得,当前、符合条件(无重复)的子串(用队列来表示);不断更新最大队列。
题解: https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/solution/hua-dong-chuang-kou-by-powcai/.
单调队列
https://www.luogu.com.cn/problem/P1886
查找
二分
剑指offer 11
题解: https://leetcode-cn.com/problems/xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-lcof/solution/xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-by-leetcode-s/.
dfs
剑指offer 12 剪枝+回溯
题解: https://leetcode-cn.com/problems/ju-zhen-zhong-de-lu-jing-lcof/solution/dfsjian-zhi-by-logilong-9w2g/
offer13 不用回溯 用
dfs
bfs
树
二叉树 | 根据前序和中序构建二叉树 |递归
剑指offer 7 寻找到根节点,对左右子树递归
题解:https://leetcode-cn.com/problems/zhong-jian-er-cha-shu-lcof/solution/mian-shi-ti-07-zhong-jian-er-cha-shu-by-leetcode-s/
二叉搜索树 | 根据后序判断 |递归
offer33
https://leetcode.cn/problems/er-cha-sou-suo-shu-de-hou-xu-bian-li-xu-lie-lcof/
二叉树 | 判断是不是子结构 | 递归 | 0902
offer26 递归,利用一个函数来判断两树是否相等,再递归。
https://leetcode-cn.com/problems/shu-de-zi-jie-gou-lcof/
二叉树 | 层序遍历输出 | 队列 | 0902
offer32 用队列进行bfs,层序输出
https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-lcof/submissions/
32-2 每输出一层就换行:
每一层放在一个数组里,出队列前记录队列中元素的个数,用for来操作下一行进队
https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-ii-lcof/solution/mian-shi-ti-32-ii-cong-shang-dao-xia-da-yin-er-c-5/