{"id":22762275,"url":"https://github.com/xusworld/basic-algos","last_synced_at":"2025-03-30T09:21:35.057Z","repository":{"id":144442260,"uuid":"353235320","full_name":"xusworld/basic-algos","owner":"xusworld","description":"基础算法。","archived":false,"fork":false,"pushed_at":"2022-05-19T05:04:42.000Z","size":502,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T11:34:04.433Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xusworld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-31T05:20:09.000Z","updated_at":"2022-05-19T04:31:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"df540d55-2b83-4853-8ec1-42778d62eea7","html_url":"https://github.com/xusworld/basic-algos","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xusworld%2Fbasic-algos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xusworld%2Fbasic-algos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xusworld%2Fbasic-algos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xusworld%2Fbasic-algos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xusworld","download_url":"https://codeload.github.com/xusworld/basic-algos/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246297537,"owners_count":20754805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-11T10:07:17.739Z","updated_at":"2025-03-30T09:21:35.049Z","avatar_url":"https://github.com/xusworld.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 程序员应该掌握的基础算法\n\n**人生少有平步青云，多是拼搏后螺旋上升。**\n\n# 1 数据结构和算法\n\n## 1.1 排序算法\n1. [插入排序(insert sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/insert_sort.h)\n2. [希尔排序(shell sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/shell_sort.h)\n3. [选择排序(selection sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/selection_sort.h)\n4. [堆排序(heap sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/heap_sort.h)\n5. [冒泡排序(bubble sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/bubble_sort.h)\n6. [快速排序(quick sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/quick_sort.h)\n7. [归并排序(merge sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/merge_sort.h)\n8. [计数排序(counting sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/counting_sort.h)\n9. [桶排序(bucket sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/bucket_sort.h)\n10. [基数排序(radix sort)](https://github.com/xusworld/basic-algos/blob/master/algos/sort/radix_sort.h)\n\n## 1.2 查找算法\n1. [顺序查找(sequence_search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/sequence_search.h)\n2. [二分查找(binary search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/binary_search.h)\n3. [插值查找(interpolation search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/interpolation_search.h)\n4. [斐波那契查找(fibonacci search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/fibonacci_search.h)\n5. [分块查找(block search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/block_search.h)\n6. [哈希查找(hash search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/hash_search.h)\n7. [指数查找(exponential search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/exponential_search.h)\n8. [跳跃查找(jump search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/jump_search.h)\n9. [无处不在的二分查找(the ubiquitous binary search)](https://github.com/xusworld/basic-algos/blob/master/algos/search/the_ubiquitous_binary_search.h)\n\n## 1.3 链表\n1. [单链表(singly linked list)](https://github.com/xusworld/basic-algos/blob/master/algos/linked_list/singly_linked_list.h)\n2. [双向链表(doubly linked list)](https://github.com/xusworld/basic-algos/blob/master/algos/linked_list/doubly_linked_list.h)\n3. [环形链表(circular linked list)](https://github.com/xusworld/basic-algos/blob/master/algos/linked_list/circular_linked_list.h)\n\n\n\n## 1.4 哈希表\n1. [hash set](https://github.com/xusworld/basic-algos/blob/master/algos/hash/hash_set.h) \n2. [hash map](https://github.com/xusworld/basic-algos/blob/master/algos/hash/hash_map.h)\n\n## 1.5 二叉树\n\n1. [前序遍历二叉树(preorder traversal)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/preorder_traversal.h)\n2. [中序遍历二叉树(inorder traversal)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/inorder_traversal.h)\n3. [后序遍历二叉树(postorder traversal)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/postorder_traversal.h)\n4. [层次遍历二叉树(level order traversal)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/level_order_traversal.h)\n5. [从前序与中序遍历序列构造二叉树](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/construct-binary-tree-from-inorder-and-postorder-traversal.h)\n6. [从中序和后序遍历序列构造二叉树](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/construct-binary-tree-from-preorder-and-inorder-traversal.h)\n7. [二叉树最大深度(maximum depth)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/maximum_depth.h)\n9. [二叉树最小深度(minimum depth)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/minimum_depth.h)\n10. [翻转二叉树(invert binary tree)](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/invert_binary_tree.h)\n11. [二叉树所有路径](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/path_sum.h)\n12. [二叉树的镜像](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/mirror_tree.h)\n13. [二叉树的最近公共祖先](https://github.com/xusworld/basic-algos/blob/master/algos/binary_tree/lowest_common_ancestor.h)\n\n\n\n## 1.6 栈\n1. [最小栈(min stack)](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/155_min_stack.h) \n\n## 1.7 堆\n1. [小顶堆(min heap)](https://github.com/xusworld/basic-algos/blob/master/algos/heap/min_heap.h)\n2. [大顶堆(max heap)](https://github.com/xusworld/basic-algos/blob/master/algos/heap/max_heap.h)\n3. [二项堆(binomial heap)](https://github.com/xusworld/basic-algos/blob/master/algos/heap/binomial_heap.h)\n4. [斐波那契堆(fibonacci heap)](https://github.com/xusworld/basic-algos/blob/master/algos/heap/fibonacci_heap.h)\n\n## 1.8 优先队列\n1. [优先队列(priority queue)](https://github.com/xusworld/basic-algos/blob/master/algos/queue/priority_queue.h)\n\n# 2 算法实战\n算法实战训练栏目中，通过一些具体的例子来训练自己对数据结构的掌握程度。\n\n## 2.1 排序\n_ 215_数组中的第K个最大元素\n_ 88_合并两个有序数组\n_ 912_排序数组\n- 148_排序链表\n- 合并排序的数组\n- 692_前K个高频单词\n- 350_两个数组的交集 II\n- 378_有序矩阵中第 K 小的元素\n- 75_颜色分类\n- 1122_数组的相对排序\n- 147_对链表进行插入排序\n- 977_有序数组的平方\n- 791_自定义字符串排序\n- 451_根据字符出现频率排序\n- 905_按奇偶排序数组\n- 922_按奇偶排序数组 II\n- 1356_根据数字二进制下 1 的数目排序\n- 280_摆动排序\n- 1387_将整数按权重排序\n- 581_最短无序连续子数组\n\n\n\n## 2.2 查找\n\n## 2.3 数组\n\n## 2.4 链表\n\n- [2. 两数相加](https://leetcode-cn.com/problems/add-two-numbers/)\n- [206.反转链表](https://leetcode-cn.com/problems/reverse-linked-list/)\n- [143. 重排链表](https://leetcode-cn.com/problems/reorder-list/)\n- [146. LRU 缓存机制](https://leetcode-cn.com/problems/lru-cache/)\n- [剑指 Offer 22. 链表中倒数第k个节点](https://leetcode-cn.com/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof/)\n- [82. 删除排序链表中的重复元素 II](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list-ii/)\n- [21. 合并两个有序链表](https://leetcode-cn.com/problems/merge-two-sorted-lists/)\n- [剑指 Offer 06. 从尾到头打印链表](https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/)\n- [141. 环形链表](https://leetcode-cn.com/problems/linked-list-cycle/)\n- [61. 旋转链表](https://leetcode-cn.com/problems/rotate-list/)\n- [19. 删除链表的倒数第 N 个结点](https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/)\n- [160. 相交链表](https://leetcode-cn.com/problems/intersection-of-two-linked-lists/)\n\n\n## 2.5 哈希表\n\n## 2.6 字符串\n\n## 2.7 队列 \n\n## 2.8 栈\n\n## 2.9 堆 \n\n## 2.10 树\n\n### 2.10.1 二叉树\n1. 二叉查找树\n2. 平衡二叉树\n3. 平衡二叉查找树（AVL 和 红黑树）\n4. 完全二叉树\n\n1. [剑指 Offer 07. 重建二叉树](https://leetcode-cn.com/problems/zhong-jian-er-cha-shu-lcof/)\n2. [226 翻转二叉树](https://leetcode-cn.com/problems/invert-binary-tree/)\n\n\n### 2.10.2 多路查找树\n\n1. B 树\n2. B+\n3. 2-3 树\n4. 2-3-4 树\n\n## 2.10 回溯算法\n\n## 2.11 贪心算法\n\n## 2.12 动态规范\n\n- [5. 最长回文子串](https://leetcode-cn.com/problems/longest-palindromic-substring/)\n- [45. 跳跃游戏 II](https://leetcode-cn.com/problems/jump-game-ii/)\n- [22. 括号生成](https://leetcode-cn.com/problems/generate-parentheses/)\n- [70. 爬楼梯](https://leetcode-cn.com/problems/climbing-stairs/)\n- [131. 分割回文串](https://leetcode-cn.com/problems/palindrome-partitioning/)\n- [121. 买卖股票的最佳时机](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/)\n- [1143. 最长公共子序列](https://leetcode-cn.com/problems/longest-common-subsequence/)\n- [322. 零钱兑换](https://leetcode-cn.com/problems/coin-change/)\n- [剑指 Offer 10- I. 斐波那契数列](https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/)\n- [139. 单词拆分](https://leetcode-cn.com/problems/word-break/)\n- [剑指 Offer 13. 机器人的运动范围](https://leetcode-cn.com/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/)\n- [494. 目标和](https://leetcode-cn.com/problems/target-sum/)\n- [剑指 Offer 10- II. 青蛙跳台阶问题](https://leetcode-cn.com/problems/qing-wa-tiao-tai-jie-wen-ti-lcof/)\n- [198. 打家劫舍](https://leetcode-cn.com/problems/house-robber/)\n- [1723. 完成所有工作的最短时间](https://leetcode-cn.com/problems/find-minimum-time-to-finish-all-jobs/)\n- [300. 最长递增子序列](https://leetcode-cn.com/problems/longest-increasing-subsequence/)\n- [55. 跳跃游戏](https://leetcode-cn.com/problems/jump-game/)\n- [221. 最大正方形](https://leetcode-cn.com/problems/maximal-square/)\n- [152. 乘积最大子数组](https://leetcode-cn.com/problems/maximum-product-subarray/)\n- [53. 最大子序和](https://leetcode-cn.com/problems/maximum-subarray/)\n- [213. 打家劫舍 II](https://leetcode-cn.com/problems/house-robber-ii/)\n- [279. 完全平方数](https://leetcode-cn.com/problems/perfect-squares/)\n- [96. 不同的二叉搜索树](https://leetcode-cn.com/problems/unique-binary-search-trees/)\n- [122. 买卖股票的最佳时机 II](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/)\n- [678. 有效的括号字符串](https://leetcode-cn.com/problems/valid-parenthesis-string/)\n- [剑指 Offer 63. 股票的最大利润](https://leetcode-cn.com/problems/gu-piao-de-zui-da-li-run-lcof/)\n- [剑指 Offer 14- I. 剪绳子](https://leetcode-cn.com/problems/jian-sheng-zi-lcof/)\n- [剑指 Offer 46. 把数字翻译成字符串](https://leetcode-cn.com/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/)\n- [338. 比特位计数](https://leetcode-cn.com/problems/counting-bits/)\n- [309. 最佳买卖股票时机含冷冻期](https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/)\n- [剑指 Offer 42. 连续子数组的最大和](https://leetcode-cn.com/problems/lian-xu-zi-shu-zu-de-zui-da-he-lcof/)\n- [LCP 07. 传递信息](https://leetcode-cn.com/problems/chuan-di-xin-xi/)\n- [64. 最小路径和](https://leetcode-cn.com/problems/minimum-path-sum/)\n- [518. 零钱兑换 II](https://leetcode-cn.com/problems/coin-change-2/)\n- [368. 最大整除子集](https://leetcode-cn.com/problems/largest-divisible-subset/)\n- [118. 杨辉三角](https://leetcode-cn.com/problems/pascals-triangle/)\n\n## 2.13 图论\n \n## 2.14 位运算\n\n1. [136 Single Number](https://leetcode.com/problems/single-number/)\n2. [137 Single Number II](https://leetcode.com/problems/single-number-ii/)\n3. [260 Single Number III](https://leetcode.com/problems/single-number-iii/)\n\n# 3 LeetCode Hot 100\n- [1. 两数之和](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/1_two_sum.h)\n- [2.两数相加](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/2_add_two_numbers.h)\n- [3. 无重复字符串的最长子串](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/3_longest_substring_without_repeating_characters.h)\n- [4. 寻找两个正序数组的中位数](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/4_median_of_two_sorted_arrays.h)\n- [5. 最长回文子串](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/5_longest_palindromic_substring.h)\n- [10. 正则表达式匹配](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/10_regular_expression_matching.h)\n- [11. 盛水最多的容器](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/11_container_with_most_water.h)\n- [15. 三数之和](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/15_3Sum.h)\n- [17. 电话号码的字母组合](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/17_letter_combinations_of_a_phone_number.h)\n- [19. 删除链表的倒数第N个结点](https://github.com/xusworld/basic-algos/blob/master/algos/leetcode/19_remove_nth_node_from_end_of_list.h)\n- [20. 有效的括号](https://leetcode.cn/problems/valid-parentheses/)\n- [21. 合并两个有序链表](https://leetcode.cn/problems/merge-two-sorted-lists/)\n- [22. 括号合成](https://leetcode.cn/problems/generate-parentheses/)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxusworld%2Fbasic-algos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxusworld%2Fbasic-algos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxusworld%2Fbasic-algos/lists"}