<p align="center">
  <a href="https://github.com/doocs/leetcode"><img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/images/leetcode-doocs.png" alt="LeetCode-GitHub-Doocs"></a>
</p>

<p align="center">
  <a href="https://github.com/doocs/leetcode"><img src="https://img.shields.io/badge/langs-Java%20%7C%20Python%20%7C%20C%2B%2B%20%7C%20JavaScript%20%7C%20Go%20%7C%20...-red?style=flat-square&color=42b883" alt="languages"></a>
  <a href="https://doocs.github.io/#/?id=how-to-join"><img src="https://img.shields.io/badge/organization-join%20us-42b883?style=flat-square" alt="open-source-organization"></a>
  <a href="https://github.com/doocs/leetcode/blob/main/LICENSE"><img src="https://img.shields.io/github/license/doocs/leetcode?color=42b883&style=flat-square" alt="LICENSE"></a><br>
  <a href="https://opencollective.com/doocs-leetcode/backers/badge.svg" alt="backers on Open Collective"><img src="https://img.shields.io/opencollective/backers/doocs-leetcode?color=42b883&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a>
  <a href="https://github.com/doocs/leetcode/stargazers"><img src="https://img.shields.io/github/stars/doocs/leetcode?color=42b883&logo=github&style=flat-square" alt="stars"></a>
  <a href="https://github.com/doocs/leetcode/network/members"><img src="https://img.shields.io/github/forks/doocs/leetcode?color=42b883&logo=github&style=flat-square" alt="forks"></a>
  <a href="https://opencollective.com/doocs-leetcode/sponsors/badge.svg" alt="Sponsors on Open Collective"><img src="https://img.shields.io/opencollective/sponsors/doocs-leetcode?color=42b883&style=flat-square&logo=open%20collective&logoColor=ffffff" /></a>
</p>

## 介绍

本项目包含 LeetCode、《剑指 Offer(第 2 版)》、《剑指 Offer(专项突击版)》、《程序员面试金典(第 6 版)》等题目的相关题解。所有题解均由多种编程语言实现,包括但不限于:Java、Python、C++、JavaScript、C#、Go,日常更新。欢迎 Star 🌟 关注[本项目](https://github.com/doocs/leetcode),获取项目最新动态。

[English Version](/README_EN.md)

## 站点

-   Gitee Pages: https://doocs.gitee.io/leetcode
-   GitHub Pages: https://doocs.github.io/leetcode

## 算法全解

-   [LeetCode](/solution/README.md)
-   [剑指 Offer(第 2 版)](/lcof/README.md)
-   [剑指 Offer(专项突击版)](/lcof2/README.md)
-   [程序员面试金典(第 6 版)](/lcci/README.md)

## 基础算法通关

### 排序算法

-   [冒泡排序](/basic/sorting/BubbleSort/README.md)
-   [插入排序](/basic/sorting/InsertionSort/README.md)
-   [选择排序](/basic/sorting/SelectionSort/README.md)
-   [归并排序(算法模板)](/basic/sorting/MergeSort/README.md)
-   [快速排序(算法模板)](/basic/sorting/QuickSort/README.md)
-   [希尔排序](/basic/sorting/ShellSort/README.md)
-   [堆排序(算法模板)](/basic/sorting/HeapSort/README.md)

### 查找算法

-   [二分查找(算法模板)](/basic/searching/BinarySearch/README.md)

## 高频考题

### 数组

-   [多数元素](/solution/0100-0199/0169.Majority%20Element/README.md)
-   [删除排序数组中的重复项](/solution/0000-0099/0026.Remove%20Duplicates%20from%20Sorted%20Array/README.md)
-   [删除排序数组中的重复项 II](/solution/0000-0099/0080.Remove%20Duplicates%20from%20Sorted%20Array%20II/README.md)
-   [移除元素](/solution/0000-0099/0027.Remove%20Element/README.md)
-   [移动零](/solution/0200-0299/0283.Move%20Zeroes/README.md)
-   [数组中重复的数字](/lcof/面试题03.%20数组中重复的数字/README.md)
-   [旋转数组](/solution/0100-0199/0189.Rotate%20Array/README.md)
-   [螺旋矩阵](/solution/0000-0099/0054.Spiral%20Matrix/README.md)
-   [两数之和](/solution/0000-0099/0001.Two%20Sum/README.md)
-   [三数之和](/solution/0000-0099/0015.3Sum/README.md)
-   [四数之和](/solution/0000-0099/0018.4Sum/README.md)
-   [较小的三数之和](/solution/0200-0299/0259.3Sum%20Smaller/README.md)
-   [最接近的三数之和](/solution/0000-0099/0016.3Sum%20Closest/README.md)
-   [合并两个有序数组](/solution/0000-0099/0088.Merge%20Sorted%20Array/README.md)
-   [寻找旋转排序数组中的最小值](/solution/0100-0199/0153.Find%20Minimum%20in%20Rotated%20Sorted%20Array/README.md)
-   [寻找旋转排序数组中的最小值 II](/solution/0100-0199/0154.Find%20Minimum%20in%20Rotated%20Sorted%20Array%20II/README.md)
-   [除自身以外数组的乘积](/solution/0200-0299/0238.Product%20of%20Array%20Except%20Self/README.md)

### 字符串

-   [无重复字符的最长子串](/solution/0000-0099/0003.Longest%20Substring%20Without%20Repeating%20Characters/README.md)
-   [最长公共前缀](/solution/0000-0099/0014.Longest%20Common%20Prefix/README.md)
-   [反转字符串中的元音字母](/solution/0300-0399/0345.Reverse%20Vowels%20of%20a%20String/README.md)
-   [字符串转换整数 (atoi)](/solution/0000-0099/0008.String%20to%20Integer%20%28atoi%29/README.md)
-   [赎金信](/solution/0300-0399/0383.Ransom%20Note/README.md)

### 链表

-   [两数相加](/solution/0000-0099/0002.Add%20Two%20Numbers/README.md)
-   [两数相加 II](/solution/0400-0499/0445.Add%20Two%20Numbers%20II/README.md)
-   [从尾到头打印链表](/lcof/面试题06.%20从尾到头打印链表/README.md)
-   [删除链表中的节点](/solution/0200-0299/0237.Delete%20Node%20in%20a%20Linked%20List/README.md)
-   [删除排序链表中的重复元素](/solution/0000-0099/0083.Remove%20Duplicates%20from%20Sorted%20List/README.md)
-   [删除排序链表中的重复元素 II](/solution/0000-0099/0082.Remove%20Duplicates%20from%20Sorted%20List%20II/README.md)
-   [移除链表元素](/solution/0200-0299/0203.Remove%20Linked%20List%20Elements/README.md)
-   [链表中倒数第 k 个节点](/lcci/02.02.Kth%20Node%20From%20End%20of%20List/README.md)
-   [两两交换链表中的节点](/solution/0000-0099/0024.Swap%20Nodes%20in%20Pairs/README.md)
-   [合并两个有序链表](/solution/0000-0099/0021.Merge%20Two%20Sorted%20Lists/README.md)
-   [合并 K 个排序链表](/solution/0000-0099/0023.Merge%20k%20Sorted%20Lists/README.md)
-   [对链表进行插入排序](/solution/0100-0199/0147.Insertion%20Sort%20List/README.md)
-   [排序链表](/solution/0100-0199/0148.Sort%20List/README.md)
-   [反转链表](/solution/0200-0299/0206.Reverse%20Linked%20List/README.md)
-   [反转链表 II](/solution/0000-0099/0092.Reverse%20Linked%20List%20II/README.md)
-   [重排链表](/solution/0100-0199/0143.Reorder%20List/README.md)
-   [旋转链表](/solution/0000-0099/0061.Rotate%20List/README.md)
-   [回文链表](/solution/0200-0299/0234.Palindrome%20Linked%20List/README.md)
-   [相交链表](/solution/0100-0199/0160.Intersection%20of%20Two%20Linked%20Lists/README.md)
-   [奇偶链表](/solution/0300-0399/0328.Odd%20Even%20Linked%20List/README.md)
-   [环形链表](/solution/0100-0199/0141.Linked%20List%20Cycle/README.md)
-   [环形链表 II](/solution/0100-0199/0142.Linked%20List%20Cycle%20II/README.md)
-   [设计链表](/solution/0700-0799/0707.Design%20Linked%20List/README.md)

### 二叉树

-   [二叉树的前序遍历](/solution/0100-0199/0144.Binary%20Tree%20Preorder%20Traversal/README.md)
-   [二叉树的后序遍历](/solution/0100-0199/0145.Binary%20Tree%20Postorder%20Traversal/README.md)
-   [二叉树的中序遍历](/solution/0000-0099/0094.Binary%20Tree%20Inorder%20Traversal/README.md)
-   [对称二叉树](/solution/0100-0199/0101.Symmetric%20Tree/README.md)
-   [树的子结构](/lcof/面试题26.%20树的子结构/README.md)
-   [翻转二叉树](/solution/0200-0299/0226.Invert%20Binary%20Tree/README.md)
-   [二叉树的层次遍历](/solution/0100-0199/0102.Binary%20Tree%20Level%20Order%20Traversal/README.md)
-   [二叉树的层次遍历 II](/solution/0100-0199/0107.Binary%20Tree%20Level%20Order%20Traversal%20II/README.md)
-   [二叉树的右视图](/solution/0100-0199/0199.Binary%20Tree%20Right%20Side%20View/README.md)
-   [二叉树的最大深度](/solution/0100-0199/0104.Maximum%20Depth%20of%20Binary%20Tree/README.md)
-   [二叉树的最小深度](/solution/0100-0199/0111.Minimum%20Depth%20of%20Binary%20Tree/README.md)
-   [二叉树的所有路径](/solution/0200-0299/0257.Binary%20Tree%20Paths/README.md)
-   [路径总和](/solution/0100-0199/0112.Path%20Sum/README.md)
-   [路径总和 II](/solution/0100-0199/0113.Path%20Sum%20II/README.md)
-   [从前序与中序遍历序列构造二叉树](/solution/0100-0199/0105.Construct%20Binary%20Tree%20from%20Preorder%20and%20Inorder%20Traversal/README.md)
-   [从中序与后序遍历序列构造二叉树](/solution/0100-0199/0106.Construct%20Binary%20Tree%20from%20Inorder%20and%20Postorder%20Traversal/README.md)
-   [二叉搜索树的后序遍历序列](/lcof/面试题33.%20二叉搜索树的后序遍历序列/README.md)
-   [二叉搜索树迭代器](/solution/0100-0199/0173.Binary%20Search%20Tree%20Iterator/README.md)
-   [二叉搜索树的最近公共祖先](/solution/0200-0299/0235.Lowest%20Common%20Ancestor%20of%20a%20Binary%20Search%20Tree/README.md)
-   [二叉树的最近公共祖先](/solution/0200-0299/0236.Lowest%20Common%20Ancestor%20of%20a%20Binary%20Tree/README.md)
-   [将二叉搜索树转换为单链表](/lcci/17.12.BiNode/README.md)
-   [将二叉搜索树转化为排序的双向链表](/solution/0400-0499/0426.Convert%20Binary%20Search%20Tree%20to%20Sorted%20Doubly%20Linked%20List/README.md)
-   [二叉树的边界](/solution/0500-0599/0545.Boundary%20of%20Binary%20Tree/README.md)
-   [填充每个节点的下一个右侧节点指针](/solution/0100-0199/0116.Populating%20Next%20Right%20Pointers%20in%20Each%20Node/README.md)
-   [填充每个节点的下一个右侧节点指针 II](/solution/0100-0199/0117.Populating%20Next%20Right%20Pointers%20in%20Each%20Node%20II/README.md)

### 数学

-   [整数转罗马数字](/solution/0000-0099/0012.Integer%20to%20Roman/README.md)
-   [罗马数字转整数](/solution/0000-0099/0013.Roman%20to%20Integer/README.md)
-   [只出现一次的数字](/solution/0100-0199/0136.Single%20Number/README.md)
-   [只出现一次的数字 II](/solution/0100-0199/0137.Single%20Number%20II/README.md)
-   [只出现一次的数字 III](/solution/0200-0299/0260.Single%20Number%20III/README.md)
-   [错误的集合](/solution/0600-0699/0645.Set%20Mismatch/README.md)
-   [位 1 的个数](/solution/0100-0199/0191.Number%20of%201%20Bits/README.md)
-   [计数质数](/solution/0200-0299/0204.Count%20Primes/README.md)
-   [不用加减乘除做加法](/lcof/面试题65.%20不用加减乘除做加法/README.md)
-   [丢失的数字](/solution/0200-0299/0268.Missing%20Number/README.md)

### 栈和队列

-   [有效的括号](/solution/0000-0099/0020.Valid%20Parentheses/README.md)
-   [最小栈](/solution/0100-0199/0155.Min%20Stack/README.md)
-   [队列的最大值](/lcof/面试题59%20-%20II.%20队列的最大值/README.md)
-   [用栈实现队列](/solution/0200-0299/0232.Implement%20Queue%20using%20Stacks/README.md)
-   [用队列实现栈](/solution/0200-0299/0225.Implement%20Stack%20using%20Queues/README.md)
-   [逆波兰表达式求值](/solution/0100-0199/0150.Evaluate%20Reverse%20Polish%20Notation/README.md)
-   [最近的请求次数](/solution/0900-0999/0933.Number%20of%20Recent%20Calls/README.md)
-   [每日温度](/solution/0700-0799/0739.Daily%20Temperatures/README.md)
-   [基本计算器 II](/solution/0200-0299/0227.Basic%20Calculator%20II/README.md)
-   [下一个更大元素 I](/solution/0400-0499/0496.Next%20Greater%20Element%20I/README.md)
-   [下一个更大元素 II](/solution/0500-0599/0503.Next%20Greater%20Element%20II/README.md)

### 动态规划

-   [斐波那契数](/solution/0500-0599/0509.Fibonacci%20Number/README.md)
-   [第 N 个泰波那契数](/solution/1100-1199/1137.N-th%20Tribonacci%20Number/README.md)
-   [爬楼梯](/solution/0000-0099/0070.Climbing%20Stairs/README.md)
-   [使用最小花费爬楼梯](/solution/0700-0799/0746.Min%20Cost%20Climbing%20Stairs/README.md)
-   [打家劫舍](/solution/0100-0199/0198.House%20Robber/README.md)
-   [打家劫舍 II](/solution/0200-0299/0213.House%20Robber%20II/README.md)
-   [删除并获得点数](/solution/0700-0799/0740.Delete%20and%20Earn/README.md)
-   [跳跃游戏](/solution/0000-0099/0055.Jump%20Game/README.md)
-   [跳跃游戏 II](/solution/0000-0099/0045.Jump%20Game%20II/README.md)
-   [最大子序和](/solution/0000-0099/0053.Maximum%20Subarray/README.md)
-   [环形子数组的最大和](/solution/0900-0999/0918.Maximum%20Sum%20Circular%20Subarray/README.md)
-   [乘积最大子序列](/solution/0100-0199/0152.Maximum%20Product%20Subarray/README.md)
-   [乘积为正数的最长子数组长度](/solution/1500-1599/1567.Maximum%20Length%20of%20Subarray%20With%20Positive%20Product/README.md)
-   [最佳观光组合](/solution/1000-1099/1014.Best%20Sightseeing%20Pair/README.md)
-   [买卖股票的最佳时机](/solution/0100-0199/0121.Best%20Time%20to%20Buy%20and%20Sell%20Stock/README.md)
-   [买卖股票的最佳时机 II](/solution/0100-0199/0122.Best%20Time%20to%20Buy%20and%20Sell%20Stock%20II/README.md)
-   [买卖股票的最佳时机 III](/solution/0100-0199/0123.Best%20Time%20to%20Buy%20and%20Sell%20Stock%20III/README.md)
-   [最佳买卖股票时机含冷冻期](/solution/0300-0399/0309.Best%20Time%20to%20Buy%20and%20Sell%20Stock%20with%20Cooldown/README.md)
-   [买卖股票的最佳时机含手续费](/solution/0700-0799/0714.Best%20Time%20to%20Buy%20and%20Sell%20Stock%20with%20Transaction%20Fee/README.md)
-   [单词拆分](/solution/0100-0199/0139.Word%20Break/README.md)
-   [接雨水](/solution/0000-0099/0042.Trapping%20Rain%20Water/README.md)
-   [等差数列划分](/solution/0400-0499/0413.Arithmetic%20Slices/README.md)
-   [解码方法](/solution/0000-0099/0091.Decode%20Ways/README.md)
-   [不同的二叉搜索树](/solution/0000-0099/0096.Unique%20Binary%20Search%20Trees/README.md)
-   [丑数 II](/solution/0200-0299/0264.Ugly%20Number%20II/README.md)
-   [杨辉三角](/solution/0100-0199/0118.Pascal%27s%20Triangle/README.md)
-   [杨辉三角 II](/solution/0100-0199/0119.Pascal%27s%20Triangle%20II/README.md)
-   [下降路径最小和](/solution/0900-0999/0931.Minimum%20Falling%20Path%20Sum/README.md)
-   [三角形最小路径和](/solution/0100-0199/0120.Triangle/README.md)
-   [矩阵区域和](/solution/1300-1399/1314.Matrix%20Block%20Sum/README.md)
-   [二维区域和检索 - 矩阵不可变](/solution/0300-0399/0304.Range%20Sum%20Query%202D%20-%20Immutable/README.md)
-   [不同路径](/solution/0000-0099/0062.Unique%20Paths/README.md)
-   [不同路径 II](/solution/0000-0099/0063.Unique%20Paths%20II/README.md)
-   [最小路径和](/solution/0000-0099/0064.Minimum%20Path%20Sum/README.md)
-   [最长回文子串](/solution/0000-0099/0005.Longest%20Palindromic%20Substring/README.md)
-   [最长回文子序列](.solution/0500-0599/0516.Longest%20Palindromic%20Subsequence/README.md)
-   [最长递增子序列](/solution/0300-0399/0300.Longest%20Increasing%20Subsequence/README.md)
-   [摆动序列](/solution/0300-0399/0376.Wiggle%20Subsequence/README.md)
-   [最长公共子序列](/solution/1100-1199/1143.Longest%20Common%20Subsequence/README.md)
-   [编辑距离](/solution/0000-0099/0072.Edit%20Distance/README.md)
-   [零钱兑换](/solution/0300-0399/0322.Coin%20Change/README.md)
-   [零钱兑换 II](/solution/0500-0599/0518.Coin%20Change%202/README.md)
-   [组合总和 Ⅳ](/solution/0300-0399/0377.Combination%20Sum%20IV/README.md)
-   [整数拆分](/solution/0300-0399/0343.Integer%20Break/README.md)
-   [完全平方数](/solution/0200-0299/0279.Perfect%20Squares/README.md)
-   [礼物的最大价值](/lcof/面试题47.%20礼物的最大价值/README.md)
-   [俄罗斯套娃信封问题](/solution/0300-0399/0354.Russian%20Doll%20Envelopes/README.md)

### 回溯算法

-   [子集](/solution/0000-0099/0078.Subsets/README.md)
-   [子集 II](/solution/0000-0099/0090.Subsets%20II/README.md)

### 并查集

-   [被围绕的区域](/solution/0100-0199/0130.Surrounded%20Regions/README.md)
-   [省份数量](/solution/0500-0599/0547.Number%20of%20Provinces/README.md)
-   [冗余连接](/solution/0600-0699/0684.Redundant%20Connection/README.md)
-   [可能的二分法](/solution/0800-0899/0886.Possible%20Bipartition/README.md)

### 设计

-   [LRU 缓存机制](/solution/0100-0199/0146.Lru%20Cache/README.md)
-   [实现 Trie (前缀树)](/solution/0200-0299/0208.Implement%20Trie%20%28Prefix%20Tree%29/README.md)
-   [实现 Trie (前缀树) II](/solution/1800-1899/1804.Implement%20Trie%20II%20%28Prefix%20Tree%29/README.md)
-   [设计循环队列](/solution/0600-0699/0622.Design%20Circular%20Queue/README.md)
-   [设计循环双端队列](/solution/0600-0699/0641.Design%20Circular%20Deque/README.md)
-   [设计哈希集合](/solution/0700-0799/0705.Design%20HashSet/README.md)
-   [设计哈希映射](/solution/0700-0799/0706.Design%20HashMap/README.md)

## 维护者

-   [Yang Libin](https://github.com/yanglbme)
-   [Mao Longlong](https://github.com/MaoLongLong)

## 加入我们

刷编程题的最大好处就是可以锻炼解决问题的思维能力。相信我,「如何去思考」​ 本身也是一项需要不断学习和练习的技能。非常感谢前微软工程师、现蚂蚁金服技术专家 [@kfstorm](https://github.com/kfstorm) 贡献了本项目的所有 [C# 题解](https://github.com/doocs/leetcode/pull/245)。

如果你对本项目感兴趣,并且希望加入我们刷题小分队,欢迎随时提交 [PR](https://github.com/doocs/leetcode/pulls)。请参考如下步骤:

1. 将本项目 fork 到你的个人 GitHub 帐户,然后 clone 到你的本地机器;
1. 对项目做出一些变更,然后使用 git add、commit、push 等命令将你的本地变更提交到你的远程 GitHub 仓库;
1. 将你的变更以 PR 的形式提交过来,项目的维护人员会在第一时间对你的变更进行 review!
1. 你也可以参考帮助文档 https://help.github.com/cn 了解更多细节。

<p align="center">
  <a href="https://github.com/doocs/leetcode"><img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/images/how-to-contribute.png" alt="how-to-contribute"></a>
</p>

[Gitpod.io](https://www.gitpod.io) 是一个免费的在线开发环境,你也可以使用它参与本项目。

<a href="https://gitpod.io/#https://github.com/doocs/leetcode" target="_blank" alt="Open in Gitpod"><img src="https://gitpod.io/button/open-in-gitpod.svg"></a>

## Stars 趋势

<a href="https://github.com/doocs/leetcode/stargazers" target="_blank"><img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/images/starcharts.svg" alt="Stargazers over time" /></a>

## 贡献者

感谢以下所有朋友对本项目的贡献!

<a href="https://github.com/doocs/leetcode/graphs/contributors" target="_blank"><img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/images/contributors.svg" /></a>

## 赞助者

感谢以下个人、组织对本项目的支持和赞助!

<a href="https://opencollective.com/doocs-leetcode/backers.svg?width=890" target="_blank"><img src="https://opencollective.com/doocs-leetcode/backers.svg?width=890"></a>

<a href="https://opencollective.com/doocs-leetcode/sponsors.svg?width=890" target="_blank"><img src="https://opencollective.com/doocs-leetcode/sponsors.svg?width=890"></a>

> "_You help the developer community practice for interviews, and there is nothing better we could ask for._" -- [Alan Yessenbayev](https://opencollective.com/alan-yessenbayev)

## 推荐者

知名互联网科技博主 [@爱可可-爱生活](https://weibo.com/fly51fly) 微博推荐。

<a href="https://weibo.com/fly51fly" target="_blank"><img src="https://cdn.jsdelivr.net/gh/doocs/leetcode@main/images/recommender-fly51fly.png"></a>

## 许可证

<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">知识共享 版权归属-相同方式共享 4.0 国际 公共许可证</a>