An open API service indexing awesome lists of open source software.

https://github.com/xusworld/basic-algos

基础算法。
https://github.com/xusworld/basic-algos

Last synced: about 1 year ago
JSON representation

基础算法。

Awesome Lists containing this project

README

          

# 程序员应该掌握的基础算法

**人生少有平步青云,多是拼搏后螺旋上升。**

# 1 数据结构和算法

## 1.1 排序算法
1. [插入排序(insert sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/insert_sort.h)
2. [希尔排序(shell sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/shell_sort.h)
3. [选择排序(selection sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/selection_sort.h)
4. [堆排序(heap sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/heap_sort.h)
5. [冒泡排序(bubble sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/bubble_sort.h)
6. [快速排序(quick sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/quick_sort.h)
7. [归并排序(merge sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/merge_sort.h)
8. [计数排序(counting sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/counting_sort.h)
9. [桶排序(bucket sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/bucket_sort.h)
10. [基数排序(radix sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/radix_sort.h)

## 1.2 查找算法
1. [顺序查找(sequence_search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/sequence_search.h)
2. [二分查找(binary search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/binary_search.h)
3. [插值查找(interpolation search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/interpolation_search.h)
4. [斐波那契查找(fibonacci search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/fibonacci_search.h)
5. [分块查找(block search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/block_search.h)
6. [哈希查找(hash search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/hash_search.h)
7. [指数查找(exponential search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/exponential_search.h)
8. [跳跃查找(jump search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/jump_search.h)
9. [无处不在的二分查找(the ubiquitous binary search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/the_ubiquitous_binary_search.h)

## 1.3 链表
1. [单链表(singly linked list)](https://github.com/xusworld/basic-algos/blob/master/algos/linked_list/singly_linked_list.h)
2. [双向链表(doubly linked list)](https://github.com/xusworld/basic-algos/blob/master/algos/linked_list/doubly_linked_list.h)
3. [环形链表(circular linked list)](https://github.com/xusworld/basic-algos/blob/master/algos/linked_list/circular_linked_list.h)

## 1.4 哈希表
1. [hash set](https://github.com/xusworld/basic-algos/blob/master/algos/hash/hash_set.h)
2. [hash map](https://github.com/xusworld/basic-algos/blob/master/algos/hash/hash_map.h)

## 1.5 二叉树

1. [前序遍历二叉树(preorder traversal)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/preorder_traversal.h)
2. [中序遍历二叉树(inorder traversal)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/inorder_traversal.h)
3. [后序遍历二叉树(postorder traversal)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/postorder_traversal.h)
4. [层次遍历二叉树(level order traversal)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/level_order_traversal.h)
5. [从前序与中序遍历序列构造二叉树](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/construct-binary-tree-from-inorder-and-postorder-traversal.h)
6. [从中序和后序遍历序列构造二叉树](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/construct-binary-tree-from-preorder-and-inorder-traversal.h)
7. [二叉树最大深度(maximum depth)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/maximum_depth.h)
9. [二叉树最小深度(minimum depth)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/minimum_depth.h)
10. [翻转二叉树(invert binary tree)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/invert_binary_tree.h)
11. [二叉树所有路径](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/path_sum.h)
12. [二叉树的镜像](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/mirror_tree.h)
13. [二叉树的最近公共祖先](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/lowest_common_ancestor.h)

## 1.6 栈
1. [最小栈(min stack)](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/155_min_stack.h)

## 1.7 堆
1. [小顶堆(min heap)](https://github.com/xusworld/basic-algos/blob/master/algos/heap/min_heap.h)
2. [大顶堆(max heap)](https://github.com/xusworld/basic-algos/blob/master/algos/heap/max_heap.h)
3. [二项堆(binomial heap)](https://github.com/xusworld/basic-algos/blob/master/algos/heap/binomial_heap.h)
4. [斐波那契堆(fibonacci heap)](https://github.com/xusworld/basic-algos/blob/master/algos/heap/fibonacci_heap.h)

## 1.8 优先队列
1. [优先队列(priority queue)](https://github.com/xusworld/basic-algos/blob/master/algos/queue/priority_queue.h)

# 2 算法实战
算法实战训练栏目中,通过一些具体的例子来训练自己对数据结构的掌握程度。

## 2.1 排序
_ 215_数组中的第K个最大元素
_ 88_合并两个有序数组
_ 912_排序数组
- 148_排序链表
- 合并排序的数组
- 692_前K个高频单词
- 350_两个数组的交集 II
- 378_有序矩阵中第 K 小的元素
- 75_颜色分类
- 1122_数组的相对排序
- 147_对链表进行插入排序
- 977_有序数组的平方
- 791_自定义字符串排序
- 451_根据字符出现频率排序
- 905_按奇偶排序数组
- 922_按奇偶排序数组 II
- 1356_根据数字二进制下 1 的数目排序
- 280_摆动排序
- 1387_将整数按权重排序
- 581_最短无序连续子数组

## 2.2 查找

## 2.3 数组

## 2.4 链表

- [2. 两数相加](https://leetcode-cn.com/problems/add-two-numbers/)
- [206.反转链表](https://leetcode-cn.com/problems/reverse-linked-list/)
- [143. 重排链表](https://leetcode-cn.com/problems/reorder-list/)
- [146. LRU 缓存机制](https://leetcode-cn.com/problems/lru-cache/)
- [剑指 Offer 22. 链表中倒数第k个节点](https://leetcode-cn.com/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof/)
- [82. 删除排序链表中的重复元素 II](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii/)
- [21. 合并两个有序链表](https://leetcode-cn.com/problems/merge-two-sorted-lists/)
- [剑指 Offer 06. 从尾到头打印链表](https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/)
- [141. 环形链表](https://leetcode-cn.com/problems/linked-list-cycle/)
- [61. 旋转链表](https://leetcode-cn.com/problems/rotate-list/)
- [19. 删除链表的倒数第 N 个结点](https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/)
- [160. 相交链表](https://leetcode-cn.com/problems/intersection-of-two-linked-lists/)

## 2.5 哈希表

## 2.6 字符串

## 2.7 队列

## 2.8 栈

## 2.9 堆

## 2.10 树

### 2.10.1 二叉树
1. 二叉查找树
2. 平衡二叉树
3. 平衡二叉查找树(AVL 和 红黑树)
4. 完全二叉树

1. [剑指 Offer 07. 重建二叉树](https://leetcode-cn.com/problems/zhong-jian-er-cha-shu-lcof/)
2. [226 翻转二叉树](https://leetcode-cn.com/problems/invert-binary-tree/)

### 2.10.2 多路查找树

1. B 树
2. B+
3. 2-3 树
4. 2-3-4 树

## 2.10 回溯算法

## 2.11 贪心算法

## 2.12 动态规范

- [5. 最长回文子串](https://leetcode-cn.com/problems/longest-palindromic-substring/)
- [45. 跳跃游戏 II](https://leetcode-cn.com/problems/jump-game-ii/)
- [22. 括号生成](https://leetcode-cn.com/problems/generate-parentheses/)
- [70. 爬楼梯](https://leetcode-cn.com/problems/climbing-stairs/)
- [131. 分割回文串](https://leetcode-cn.com/problems/palindrome-partitioning/)
- [121. 买卖股票的最佳时机](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/)
- [1143. 最长公共子序列](https://leetcode-cn.com/problems/longest-common-subsequence/)
- [322. 零钱兑换](https://leetcode-cn.com/problems/coin-change/)
- [剑指 Offer 10- I. 斐波那契数列](https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/)
- [139. 单词拆分](https://leetcode-cn.com/problems/word-break/)
- [剑指 Offer 13. 机器人的运动范围](https://leetcode-cn.com/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/)
- [494. 目标和](https://leetcode-cn.com/problems/target-sum/)
- [剑指 Offer 10- II. 青蛙跳台阶问题](https://leetcode-cn.com/problems/qing-wa-tiao-tai-jie-wen-ti-lcof/)
- [198. 打家劫舍](https://leetcode-cn.com/problems/house-robber/)
- [1723. 完成所有工作的最短时间](https://leetcode-cn.com/problems/find-minimum-time-to-finish-all-jobs/)
- [300. 最长递增子序列](https://leetcode-cn.com/problems/longest-increasing-subsequence/)
- [55. 跳跃游戏](https://leetcode-cn.com/problems/jump-game/)
- [221. 最大正方形](https://leetcode-cn.com/problems/maximal-square/)
- [152. 乘积最大子数组](https://leetcode-cn.com/problems/maximum-product-subarray/)
- [53. 最大子序和](https://leetcode-cn.com/problems/maximum-subarray/)
- [213. 打家劫舍 II](https://leetcode-cn.com/problems/house-robber-ii/)
- [279. 完全平方数](https://leetcode-cn.com/problems/perfect-squares/)
- [96. 不同的二叉搜索树](https://leetcode-cn.com/problems/unique-binary-search-trees/)
- [122. 买卖股票的最佳时机 II](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/)
- [678. 有效的括号字符串](https://leetcode-cn.com/problems/valid-parenthesis-string/)
- [剑指 Offer 63. 股票的最大利润](https://leetcode-cn.com/problems/gu-piao-de-zui-da-li-run-lcof/)
- [剑指 Offer 14- I. 剪绳子](https://leetcode-cn.com/problems/jian-sheng-zi-lcof/)
- [剑指 Offer 46. 把数字翻译成字符串](https://leetcode-cn.com/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/)
- [338. 比特位计数](https://leetcode-cn.com/problems/counting-bits/)
- [309. 最佳买卖股票时机含冷冻期](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/)
- [剑指 Offer 42. 连续子数组的最大和](https://leetcode-cn.com/problems/lian-xu-zi-shu-zu-de-zui-da-he-lcof/)
- [LCP 07. 传递信息](https://leetcode-cn.com/problems/chuan-di-xin-xi/)
- [64. 最小路径和](https://leetcode-cn.com/problems/minimum-path-sum/)
- [518. 零钱兑换 II](https://leetcode-cn.com/problems/coin-change-2/)
- [368. 最大整除子集](https://leetcode-cn.com/problems/largest-divisible-subset/)
- [118. 杨辉三角](https://leetcode-cn.com/problems/pascals-triangle/)

## 2.13 图论

## 2.14 位运算

1. [136 Single Number](https://leetcode.com/problems/single-number/)
2. [137 Single Number II](https://leetcode.com/problems/single-number-ii/)
3. [260 Single Number III](https://leetcode.com/problems/single-number-iii/)

# 3 LeetCode Hot 100
- [1. 两数之和](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/1_two_sum.h)
- [2.两数相加](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/2_add_two_numbers.h)
- [3. 无重复字符串的最长子串](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/3_longest_substring_without_repeating_characters.h)
- [4. 寻找两个正序数组的中位数](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/4_median_of_two_sorted_arrays.h)
- [5. 最长回文子串](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/5_longest_palindromic_substring.h)
- [10. 正则表达式匹配](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/10_regular_expression_matching.h)
- [11. 盛水最多的容器](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/11_container_with_most_water.h)
- [15. 三数之和](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/15_3Sum.h)
- [17. 电话号码的字母组合](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/17_letter_combinations_of_a_phone_number.h)
- [19. 删除链表的倒数第N个结点](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/19_remove_nth_node_from_end_of_list.h)
- [20. 有效的括号](https://leetcode.cn/problems/valid-parentheses/)
- [21. 合并两个有序链表](https://leetcode.cn/problems/merge-two-sorted-lists/)
- [22. 括号合成](https://leetcode.cn/problems/generate-parentheses/)