{"id":17923894,"url":"https://github.com/lilittlecat/algorithm-study-notes","last_synced_at":"2025-06-13T12:34:26.704Z","repository":{"id":122591506,"uuid":"288154825","full_name":"LiLittleCat/algorithm-study-notes","owner":"LiLittleCat","description":"我的算法学习笔记，部分内容来自互联网，并已标明出处，如有侵权，请联系删除。","archived":false,"fork":false,"pushed_at":"2022-01-17T11:12:02.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T09:23:06.390Z","etag":null,"topics":["algorithms","java","leetcode"],"latest_commit_sha":null,"homepage":"","language":"Java","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/LiLittleCat.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":"2020-08-17T10:50:36.000Z","updated_at":"2023-02-21T03:31:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"ec9eaab3-09c4-4e31-a20f-0af30c260d44","html_url":"https://github.com/LiLittleCat/algorithm-study-notes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LiLittleCat/algorithm-study-notes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiLittleCat%2Falgorithm-study-notes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiLittleCat%2Falgorithm-study-notes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiLittleCat%2Falgorithm-study-notes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiLittleCat%2Falgorithm-study-notes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiLittleCat","download_url":"https://codeload.github.com/LiLittleCat/algorithm-study-notes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiLittleCat%2Falgorithm-study-notes/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259645440,"owners_count":22889606,"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":["algorithms","java","leetcode"],"created_at":"2024-10-28T20:46:06.134Z","updated_at":"2025-06-13T12:34:26.667Z","avatar_url":"https://github.com/LiLittleCat.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :sparkling_heart: 算法学习笔记\n\n我的算法学习笔记，部分内容来自互联网，并已标明出处，如有侵权，请联系删除。\n\n本仓库遵循 [中文文案排版指北](https://github.com/sparanoid/chinese-copywriting-guidelines)。\n\n## :thinking: 框架思维\n\n整理自 [labuladong 的算法小抄](https://github.com/labuladong/fucking-algorithm)。\n\n**数据结构的存储方式**\n\n- 数组（顺序存储）\n- 链表（链式存储）\n\n各种数据结构都是在数组或者链表上的特殊操作，底层都是数组或者链表实现的。\n\n特点：\n\n- 数组：可随机访问，相对节约空间；扩容、插入或删除时间复杂度 O(N)。\n- 链表：不可随机访问，消耗更多空间；扩容、插入或删除时间复杂度 O(1)。\n\n**数据结构的操作**\n\n- 遍历 + 访问\n  - 线性（迭代）\n  - 非线性（递归）\n\n**框架**\n\n数组遍历框架（线性迭代）\n\n```java\nvoid traverse(int[] arr) {\n    for (int i = 0;i \u003c arr.length;i++) {\n        // 迭代访问 arr[i]\n    }\n}\n```\n\n链表遍历框架（兼具迭代和递归）\n\n```java\n/* 基本的单链表节点 */\nclass ListNode {\n    int val;\n    ListNode next;\n}\n\nvoid traverse(ListNode head) {\n    for (ListNode p = head;p != null;p = p.next) {\n        // 迭代访问 p.val\n    }\n}\n\nvoid traverse(ListNode head) {\n    // 迭代访问 head.val\n    traverse(head.val);\n}\n```\n\n二叉树遍历框架（非线性递归）\n\n```java\n/* 基本的二叉树节点 */\nclass TreeNode {\n    int val;\n    TreeNode left, right;\n}\n\nvoid traverse(TreeNode root) {\n    // 前序遍历\n    traverse(root.left);\n    // 中序遍历\n    traverse(root.right);\n    // 后序遍历\n}\n\n```\n\n N 叉树的遍历框架\n\n```java\n/* 基本的 N 叉树节点 */\nclass TreeNode {\n    int val;\n    TreeNode[] children;\n}\n\nvoid traverse(TreeNode root) {\n    for (TreeNode child : root.children)\n        traverse(child);\n}\n```\n\n回溯算法框架\n\n```java\nresult = []\ndef backtrack（路径，选择列表）:\n    if 满⾜结束条件：\n        result.add（路径）\n        return\n    for 选择 in 选择列表：\n        做选择\n        backtrack（路径，选择列表）\n        撤销选择\n```\n\n 动态规划框架\n\n```java\n# 初始化 base case\ndp[0][0][...] = base\n# 进⾏状态转移\nfor 状态 1 in 状态 1 的所有取值：\n    for 状态 2 in 状态 2 的所有取值：\n        for ...\n            dp[状态 1][状态 2][...] = 求最值（选择 1，选择 2...)\n```\n\n## :blue_book: LeetBook\n\n- :sparkles:[初级算法](https://github.com/LiLittleCat/leetcode-solutions/blob/master/leetbook/top-interview-questions-easy.md)\n\n- ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flilittlecat%2Falgorithm-study-notes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flilittlecat%2Falgorithm-study-notes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flilittlecat%2Falgorithm-study-notes/lists"}