# python-algorithm **Repository Path**: mark2root/python-algorithm ## Basic Information - **Project Name**: python-algorithm - **Description**: 老宋秋招刷题日记, 语言使用python 与 c++ - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-10 - **Last Updated**: 2021-12-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Introduction 本仓库是我在准备 2020 届秋招时所刷过的题,刷题对于找工作的重要性不言而喻, 如果你现在还没有开始,我的建议是从明天开始,一天5道。 如果你按照我的这个仓库的目录进行刷题,刷个两三遍,对于每道题都能很快的产生思路, 那么毕业找工作的时候,BAT 面试时候的手撸算法这关,你是完全没有问题的。 该仓库大概包含 300+ 道编程题, 是由我个人筛选的, 基本所有的知识点都有涉及到,目前仓库还在更新中,预计12月底完成。 - docs: 该文件夹下包含了诸多数据结构基础知识,如果对哪一方面不熟悉可以参考一下 [TOC] ## 1. 链表 ### 1. 剑指 offer | [offer 6: 从头到尾打印链表](https://www.nowcoder.com/practice/d0267f7f55b3412ba93bd35cfa8e8035?tpId=13&tqId=11156&tPage=1&rp=1&ru=%2Fta%2Fcoding-interviews&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking) | [offer 18 :删除链表中重复的节点]() | [offer 22: 链表中的倒数第 k 个节点]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [offer 23: 链表中环的入口节点]() | [offer 25: 反转链表]() | [offer 25: 合并两个排序的链表]() | | [offer 35: 复杂链表的复制]() | [offer 52: 两个链表的第一个公共节点]() | | ### 2. Leetcode Easy | [leetcode 206: 反转链表]() | [leetcode 160: 链表相交]() | [leetcode 21: 排序链表的合并]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 234: 回文链表]() | [leetcode 237: 删除链表中的节点]() | [leetcode 83: 删除排序链表中重复的节点]() | | [leetcode 203: 移除链表元素]() | | | ### 3. Leetcode Medium | [leetcode 92:反转链表]() | [leetcode 141: 环形链表]() | [leetcode 142: 环形链表2]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 86: 链表划分]() | [leetcode 138: 复制带随机指针的链表]() | [leetcode 2: 两数相加]() | | [leetcode 148:排序链表]() | [leetcode 328: 奇偶链表]() | [leetcode 445: 两数相加2]() | | [leetcode 82: 删除排序链表中的重复元素2]() | [leetcode 24: 两两交换链表中的节点]() | [leetcode 147: 对链表进行插入排序]() | | [leetcode 148: 排序链表]() | [leetcode 19: 删除链表的倒数第 N 个节点]() | [leetcode 61: 旋转链表]() | | [leetcode 143: 重排链表]() | | | ### 4. Leetcode Hard | [leetcode 23: 合并 k 个有序链表]() | [leetcode 25: k 个一组翻转链表]() | | | ------------------------------------------------------------ | ------------------------------------------------------------ | ---- | | | | | ## 2. 数组 ### 1. 剑指 offer | [offer 3:数组中重复的数字](https://www.nowcoder.com/practice/623a5ac0ea5b4e5f95552655361ae0a8?tpId=13&tqId=11203&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking) | [offer 4:二维数组的查找](https://www.nowcoder.com/practice/abc3fe2ce8e146608e868a70efebf62e?tpId=13&tqId=11154&tPage=1&rp=1&ru=%2Fta%2Fcoding-interviews&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking) | [offer 11: 旋转数组中的最小数字]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [offer 21: 调整数组的顺序]() | [offer 39: 数组中出现次数超过一半的数字]() | [offer 40: 最小 k 个数]() | | [offer 41: 数据流中的中位数]() | [offer 42: 连续子数组的最大和]() | [offer 43: 1出现的次数]() | | [offer 44: 数字序列中的某一位数字]() | [offer 45: 把数组排成最小的数]() | [offer 46: 把数字翻译成字符串]() | | [offer 51: 数组中的逆序对]() | [offer 53: 排序数组中查找数字]() | [offer 56:数组中只出现一次的两个数字]() | | [offer 57:和为 s 的两个数字]() | [offer 61:扑克牌的顺子]() | [offer 63: 股票的最大利润]() | | [offer 66: 构建乘积数组]() | [offer 59:滑动窗口最大值]() | | ### 2. Leetcode Easy | [leetcode 283: 移动零]() | [leetcode 27: 移除元素]() | [leetcode 26:删除排序数组中的重复项]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 88: 合并两个有序数组]() | [leetcode 167: 两数之和 2]() | [leetcode 400: 第 N 个数]() | | [leetcode 1: 两数之和]() | [leetcode 121: 买卖股票的最佳时机]() | [leetcode 136: 只出现一次的数字]() | | [leetcode 169: 求众数]() | [leetcode 448: 找到所有数组中消失的数字]() | [leetcode 581: 最短无序连续子数组]() | | | | | ### 3. Leetcode Medium | [leetcode 80: 删除排序数组中的重复项2]() | [leetcode 75: 颜色分类]() | [leetcode 215: 数组中的第 k 个最大元素]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 11: 盛最多水的容器]() | [leetcode 209: 长度最小的子数组]() | [leetcode 238: 除自身之外的乘积]() | | [leetcode 91: 解码方法]() | [leetcode 15: 三数之和]() | [leetcode 287: 寻找重复数]() | | [leetcode 338: 比特位计数]() | [leetcode 347: 前 k 个高频元素]() | [leetcode 406: 根据身高重建队列]() | | [leetcode 523: 连续的子数组和]() | [leetcode 739: 每日温度]() | [leetcode 795: 区间子数组个数]() | ### 4. Leetcode Hard | [leetcode 128: 最长连续序列]() | | | | ------------------------------------------------------------ | ---- | ---- | | | | | ## 3. 字符串 ### 1. 剑指 offer ### 2. Leetcode Easy | [leetcode 344: 反转字符串]() | [leetcode 345: 反转字符串中的元音字母]() | [leetcode 438: 找到字符串中的所有字母异位词]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | | | | | | | | ### 3. Leetcode Medium | [leetcode 3: 无重复字符的最长子串]() | | | | ------------------------------------------------------------ | ---- | ---- | | | | | ### 4. Leetcode Hard | [leetcode 76: 最小覆盖子串]() | | | | ------------------------------------------------------------ | ---- | ---- | | | | | ## 4. 回文串 ### 1. Leetcode Easy | [leetcode 125: 验证回文串]() | | | | ------------------------------------------------------------ | ---- | ---- | | | | | ## 5. 栈-队列-堆 ### 1. 剑指 offer | [offer 9: 两个栈实现队列]() | [offer 9: 两个队列实现一个栈]() | [offer 30:包含 min 函数的栈]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [offer 31:栈的压入,弹出序列]() | | | ### 2. Leetcode Easy | [leetcode 225: 用队列实现栈]() | [leetcode 232: 用栈实现队列]() | [leetcode 155: 最小栈]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 20: 有效的括号]() | | | ### 3. Leetcode Medium | [leetcode 215: 数组中的第 k 个最大元素]() | [leetcode 946: 验证栈序列]() | | | ------------------------------------------------------------ | ------------------------------------------------------------ | ---- | | | | | ### 4. Leetcode Hard | [leetcode 224: 基本计算器]() | [leetcode 295: 数据流的中位数]() | | | ------------------------------------------------------------ | ------------------------------------------------------------ | ---- | | | | | ## 6. 二叉树 ### 1. 剑指offer | [重建二叉树](https://www.nowcoder.com/practice/8a19cbe657394eeaac2f6ea9b0f6fcf6?tpId=13&tqId=11157&tPage=1&rp=1&ru=%2Fta%2Fcoding-interviews&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking) | [二叉树的下一个节点](https://www.nowcoder.com/practice/9023a0c988684a53960365b889ceaf5e?tpId=13&tqId=11210&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking) | [树的子结构]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [二叉树的镜像]() | [对称的二叉树]() | [不分行从上到下打印二叉树]() | | [分行从上到下打印二叉树]() | [之字形打印二叉树]() | [二叉树的后序遍历序列]() | | [二叉树中和为某一值的路径]() | [二叉搜索树转化为双向链表]() | [序列化二叉树]() | | [二叉搜索树的第 k 大节点]() | [二叉树的深度]() | [平衡二叉树]() | ### 2. Leetcode Easy | [leetcode 104: 二叉树最大深度]() | [leetcode 111:二叉树的最小深度]() | [leetcode 226 :翻转二叉树]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 100: 相同的树]() | [leetcode 112: 路径总和]() | [leetcode 404: 左叶子之和]() | | [leetcode 257: 二叉树所有路径]() | [leetcode 437: 路径总和3]() | [leetcode 235: 二叉搜索树的最近公共祖先]() | | [leetcode 108: 将有序数组转化为二叉搜索树]() | | | ### 3. Leetcode Medium | [leetcode 144: 二叉树前序遍历]() | [leetcode 94: 二叉树的中序遍历]() | [leetcode 102: 二叉树的层序遍历]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 96: 不同的二叉搜索树]() | [leetcode 105: 从前序和中序遍历构造二叉树]() | [leetcode 98: 二叉搜索树]() | | [leetcode 333: 最大BST子树]() | [leetcode 958:完全二叉树]() | [leetcode 110: 平衡二叉树]() | | [leetcode 543: 二叉树的直径]() | [leetcode 222: 完全二叉树节点个数]() | [leetcode 1038: 从二叉搜索树到更大和树]() | | [leetcode 662: 二叉树最大宽度]() | [leetcode 101: 对称二叉树]() | [leetcode 199:二叉树的右视图]() | | [leetcode 113: 路径总和 2]() | [leetcode 129: 求根到叶子节点数字之和]() | [leetcode 450: 删除二叉搜索树中的节点]() | | [leetcode 230: 二叉搜索树中的第 k 小的元素]() | [leetcode 236: 二叉树的最近公共祖先]() | | | | | | ### 4. Leetcode Hard | [leetcode 145: 二叉树的后序遍历]() | | | | ------------------------------------------------------------ | ---- | ---- | | | | | ## 查找问题 这里指的查找问题主要包括以下两类: - 查找元素 `a` 是否存在? 一般采用集合 Set 来做。 - 查找元素 `a` 出现了几次? 一般采用字典 Dict 来做。 ### 1. 剑指offer ### 2. Leetcode Easy | [leetcode 349: 两个数组的交集]() | [leetcode 350: 两个数组的交集 2]() | [leetcode 242: 有效的字母异位词]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 202: 快乐数]() | [leetcode 290: 单词规律]() | [leetcode 205: 同构字符串]() | | [leetcode 1: 两数之和]() | [leetcode 447: 回旋镖的数量]() | [leetcode 219: 存在重复元素2]() | | [leetcode 217:存在重复元素]() | | | ### 3. Leetcode Medium | [leetcode 451: 根据字符出现频率排序]() | [leetcode 15: 三数之和]() | [leetcode 16: 最接近的三数之和]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 454: 四数相加2]() | [leetcode 49: 字母异位词分组]() | [leetcode 220:存在重复元素3]() | | | | | | | | | ### 4. Leetcode Hard | [leetcode 149: 直线上最多的点数]() | | | | ------------------------------------------------------------ | ---- | ---- | | | | | ## 二分查找 ### 1. 剑指offer ### 2. Leetcode Easy | [leetcode 704: 二分查找]() | | | | ------------------------------------------------------------ | ---- | ---- | | | | | ## 回溯法 ### 1. 剑指offer | [offer 12: 矩阵中的路径]() | [offer 13: 机器人的运动范围]() | [offer 64: 求1+...+n]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | | | | ### 2. Leetcode Easy | [leetcode 401: 二进制手表]() | [leetcode 784: 字母大小写全排列]() | | | ------------------------------------------------------------ | ------------------------------------------------------------ | ---- | | | | | ### 3. Leetcode Medium | [Leetcode 17: 电话号码的字母组合]() | [leetcode 131: 分割回文串]() | [leetcode 45: 全排列]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 47: 全排列2]() | [leetcode 77: 组合]() | [leetcode 39: 组合总和]() | | [leetcode 40: 组合总和2]() | [leetcode 216:组合总和3]() | [leetcode 78:子集]() | | [leetcode 90: 子集2]() | [leetcode 79: 单词搜索]() | [leetcode 200: 岛屿数量]() | | [leetcode 130: 被围绕的区域]() | [leetcode 417: 太平洋大西洋水流问题]() | [leetcode 207: 课程表]() | | | | | ### 4. Leetcode Hard | [leetcode 51: N皇后问题]() | [leetcode 52: N皇后问题2]() | [leetcode 37: 解数独]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | | | | ## 贪心算法 ### 1. Leetcode Easy | [leetcode 944: 删列造序]() | [leetcode 1046: 最后一块石头的重量]() | [leetcode 122: 买卖股票的最佳时机2]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------- | | | | | | | | | | | | | ## 动态规划 ### 1. 剑指 offer | [斐波那契数列]() | [青蛙跳台阶问题]() | [变态跳台阶]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [矩形覆盖]() | [剪绳子]() | [offer 49: 丑数]() | | | | | | | | | ### 2. Leetcode Easy | [leetcode 1025:除数博弈]() | [leetcode 70: 爬楼梯]() | [leetcode 198:打家劫舍]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 53]() | | | | | | | ### 3. Leetcode Medium | [leetcode 322: 零钱兑换]() | [leetcode 120: 三角形最小路径和]() | [leetcode 300: 最长上升子序列]() | | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | [leetcode 64: 最小路径和]() | | | | | | | ### 4. Hard | [leetcode 174: 地下城游戏]() | | | | :----------------------------------------------------------- | ---- | ---- | | | | |