{"id":19216289,"url":"https://github.com/huangrunhua/leetcode-swift","last_synced_at":"2025-10-14T19:04:49.646Z","repository":{"id":181963466,"uuid":"643817812","full_name":"HuangRunHua/leetcode-swift","owner":"HuangRunHua","description":"Swift Solution for LeetCode | LeetCode Swift 题解","archived":false,"fork":false,"pushed_at":"2024-01-16T04:16:14.000Z","size":5025,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-14T19:03:31.516Z","etag":null,"topics":["coding-challenges","coding-interviews","leetcode","leetcode-solutions","leetcode-swift","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/HuangRunHua.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":"2023-05-22T08:12:24.000Z","updated_at":"2024-08-23T14:09:02.000Z","dependencies_parsed_at":"2024-01-16T04:43:48.507Z","dependency_job_id":null,"html_url":"https://github.com/HuangRunHua/leetcode-swift","commit_stats":null,"previous_names":["huangrunhua/leetcode-swift"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HuangRunHua/leetcode-swift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuangRunHua%2Fleetcode-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuangRunHua%2Fleetcode-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuangRunHua%2Fleetcode-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuangRunHua%2Fleetcode-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HuangRunHua","download_url":"https://codeload.github.com/HuangRunHua/leetcode-swift/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HuangRunHua%2Fleetcode-swift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020607,"owners_count":26086895,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["coding-challenges","coding-interviews","leetcode","leetcode-solutions","leetcode-swift","swift"],"created_at":"2024-11-09T14:16:35.418Z","updated_at":"2025-10-14T19:04:49.616Z","avatar_url":"https://github.com/HuangRunHua.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swift Solution for LeetCode Coding Interviews\n### 字符串\n\n#### 简单\n\n[剑指 Offer 05. 替换空格](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer05-替换空格.playground/Contents.swift)\n\n[剑指 Offer 58 - II. 左旋转字符串](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer58-II-左旋转字符串.playground/Contents.swift)\n\n#### 中等\n\n[剑指 Offer 20. 表示数值的字符串](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer20-表示数值的字符串.playground/Contents.swift)\n\n[剑指 Offer 20. 表示数值的字符串 (解法2: 更通俗易懂的有限状态自由机)](https://github.com/HuangRunHua/leetcode-swift/blob/main/剑指Offer/剑指Offer20-表示数值的字符串解法二.playground/Contents.swift)\n\n[剑指 Offer 67. 把字符串转换成整数](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer67-把字符串转换成整数.playground/Contents.swift)\n\n[剑指 Offer 67. 把字符串转换成整数 (解法2: 有限状态自由机)](https://github.com/HuangRunHua/leetcode-swift/blob/main/剑指Offer/剑指Offer67-把字符串转换成整数解法2.playground/Contents.swift)\n\n### 链表\n\n#### 简单\n\n[剑指 Offer 06. 从尾到头打印链表](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer06-从尾到头打印链表.playground/Contents.swift)\n\n[剑指 Offer 24. 反转链表](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer24-反转链表.playground/Contents.swift)\n\n#### 中等\n\n[剑指 Offer 35. 复杂链表的复制](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer35-复杂链表的复制.playground/Contents.swift)\n\n### 双指针\n\n#### 简单\n\n[剑指 Offer 18. 删除链表的节点](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer18-删除链表的节点.playground/Contents.swift)\n\n[剑指 Offer 22. 链表中倒数第k个节点](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer22-链表中倒数第k个节点.playground/Contents.swift)\n\n[剑指 Offer 25. 合并两个排序的链表](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer25-合并两个排序的链表.playground/Contents.swift)\n\n[剑指 Offer 52. 两个链表的第一个公共节点](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer52-两个链表的第一个公共节点.playground/Contents.swift)\n\n[剑指 Offer 21. 调整数组顺序使奇数位于偶数前面](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer21调整数组顺序使奇数位于偶数前面.playground/Contents.swift)\n\n[剑指 Offer 57. 和为s的两个数字](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer57-和为s的两个数字.playground/Contents.swift)\n\n[剑指 Offer 58 - I. 翻转单词顺序](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer58-I-翻转单词顺序.playground/Contents.swift)\n\n### 栈与队列\n\n#### 简单\n\n[剑指 Offer 09. 用两个栈实现队列](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer09-用两个栈实现队列.playground/Contents.swift)\n\n[剑指 Offer 30. 包含min函数的栈](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer30-包含min函数的栈.playground/Contents.swift)\n\n#### 中等\n\n[剑指 Offer 59 - II. 队列的最大值](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer59-II-队列的最大值.playground/Contents.swift)\n\n#### 困难\n\n[剑指 Offer 59 - I. 滑动窗口的最大值](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer59-I-滑动窗口的最大值.playground/Contents.swift)\n\n### 模拟\n\n#### 简单\n\n[剑指 Offer 29. 顺时针打印矩阵](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer29-顺时针打印矩阵.playground/Contents.swift)\n\n#### 中等\n\n[剑指 Offer 31. 栈的压入、弹出序列](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer31-栈的压入弹出序列.playground/Contents.swift)\n\n### 查找算法\n\n#### 简单\n\n[剑指 Offer 03. 数组中重复的数字](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer03-数组中重复的数字.playground/Contents.swift)\n\n[剑指 Offer 53 - I. 在排序数组中查找数字 I](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer53-I-在排序数组中查找数字%20I.playground/Contents.swift)\n\n[剑指 Offer 53 - II. 0～n-1中缺失的数字](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer53-II0-n-1中缺失的数字.playground/Contents.swift)\n\n[剑指 Offer 11. 旋转数组的最小数字](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer11-旋转数组的最小数字%20.playground/Contents.swift)\n\n[剑指 Offer 50. 第一个只出现一次的字符](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer50-第一个只出现一次的字符.playground/Contents.swift)\n\n#### 中等\n\n[剑指 Offer 04. 二维数组中的查找](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer04-二维数组中的查找.playground/Contents.swift)\n\n### 搜索与回溯算法\n\n#### 简单\n\n[剑指 Offer 32 - II. 从上到下打印二叉树 II](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer32-II-从上到下打印二叉树%20II.playground/Contents.swift)\n\n[剑指 Offer 27. 二叉树的镜像](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer27-二叉树的镜像.playground/Contents.swift)\n\n[剑指 Offer 28. 对称的二叉树](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer28-对称的二叉树.playground/Contents.swift)\n\n[剑指 Offer 54. 二叉搜索树的第k大节点](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer54-二叉搜索树的第k大节点.playground/Contents.swift)\n\n[剑指 Offer 55 - I. 二叉树的深度](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer55-I-二叉树的深度.playground/Contents.swift)\n\n[剑指 Offer 55 - II. 平衡二叉树](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer55-II-平衡二叉树.playground/Contents.swift)\n\n[剑指 Offer 68 - I. 二叉搜索树的最近公共祖先](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer68-I二叉搜索树的最近公共祖先.playground/Contents.swift)\n\n[剑指 Offer 68 - II. 二叉树的最近公共祖先](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer68-II-二叉树的最近公共祖先.playground/Contents.swift)\n\n#### 中等\n\n[剑指 Offer 32 - I. 从上到下打印二叉树](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer32-I-从上到下打印二叉树.playground/Contents.swift)\n\n[剑指 Offer 32 - III. 从上到下打印二叉树 III](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer32-III-从上到下打印二叉树%20III.playground/Contents.swift)\n\n[剑指 Offer 26. 树的子结构](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer26-树的子结构.playground/Contents.swift)\n\n[剑指 Offer 12. 矩阵中的路径](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer12-矩阵中的路径.playground/Contents.swift)\n\n[剑指 Offer 13. 机器人的运动范围](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer13-机器人的运动范围.playground/Contents.swift)\n\n[剑指 Offer 34. 二叉树中和为某一值的路径](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer34-二叉树中和为某一值的路径.playground/Contents.swift)\n\n[剑指 Offer 36. 二叉搜索树与双向链表](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer36-二叉搜索树与双向链表.playground/Contents.swift)\n\n[剑指 Offer 64. 求1+2+…+n](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer64-求1%2B2%2B…%2Bn.playground/Contents.swift)\n\n[剑指 Offer 38. 字符串的排列 (解法1)](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer38-字符串的排列.playground/Contents.swift)\n\n[剑指 Offer 38. 字符串的排列 (解法2)](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer38-字符串的排列解法2.playground/Contents.swift)\n\n#### 困难\n\n[剑指 Offer 37. 序列化二叉树](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer37-序列化二叉树.playground/Contents.swift)\n\n### 分治算法\n\n#### 简单\n\n[剑指 Offer 17. 打印从1到最大的n位数](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer17-打印从1到最大的n位数.playground/Contents.swift)\n\n#### 中等\n\n[剑指 Offer 07. 重建二叉树](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer07-重建二叉树.playground/Contents.swift)\n\n[剑指 Offer 16. 数值的整数次方](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer16-数值的整数次方.playground/Contents.swift)\n\n[剑指 Offer 33. 二叉搜索树的后序遍历序列](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer33-二叉搜索树的后序遍历序列.playground/Contents.swift)\n\n#### 困难\n\n[剑指 Offer 51. 数组中的逆序对](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer51-数组中的逆序对.playground/Contents.swift)\n\n### 排序\n\n#### 简单\n\n[剑指 Offer 61. 扑克牌中的顺子](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer61-扑克牌中的顺子.playground/Contents.swift)\n\n[剑指 Offer 40. 最小的k个数](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer40-最小的k个数.playground/Contents.swift)\n\n#### 中等\n\n[剑指 Offer 45. 把数组排成最小的数](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer45-把数组排成最小的数.playground/Contents.swift)\n\n#### 困难\n\n[剑指 Offer 41. 数据流中的中位数](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer41-数据流中的中位数.playground/Contents.swift)\n\n### 动态规划\n\n#### 简单\n\n[剑指 Offer 10- I. 斐波那契数列](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer10-I-斐波那契数列.playground/Contents.swift)\n\n[剑指 Offer 10- II. 青蛙跳台阶问题](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer10-II-青蛙跳台阶问题.playground/Contents.swift)\n\n[剑指 Offer 42. 连续子数组的最大和](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer42-连续子数组的最大和.playground/Contents.swift)\n\n[剑指 Offer 42. 连续子数组的最大和(模板套路解法)](https://github.com/HuangRunHua/leetcode-swift/blob/main/剑指Offer/剑指Offer42-连续子数组的最大和(解法2).playground/Contents.swift)\n\n#### 中等\n\n[剑指 Offer 63. 股票的最大利润](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer63-股票的最大利润.playground/Contents.swift)\n\n[剑指 Offer 47. 礼物的最大价值](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer47-礼物的最大价值.playground/Contents.swift)\n\n[剑指 Offer 46. 把数字翻译成字符串](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer46-把数字翻译成字符串.playground/Contents.swift)\n\n[剑指 Offer 48. 最长不含重复字符的子字符串](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer48-最长不含重复字符的子字符串.playground/Contents.swift)\n\n[剑指 Offer 49. 丑数](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer49-丑数.playground/Contents.swift)\n\n[剑指 Offer 60. n个骰子的点数](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer60-n个骰子的点数.playground/Contents.swift)\n\n#### 困难\n\n[剑指 Offer 19. 正则表达式匹配](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer19-正则表达式匹配.playground/Contents.swift)\n\n[剑指 Offer 19. 正则表达式匹配解法2](https://github.com/HuangRunHua/leetcode-swift/blob/main/剑指Offer/剑指Offer19.正则表达式匹配解法2.playground/Contents.swift)\n\n### 位运算\n\n#### 简单\n\n[剑指 Offer 15. 二进制中1的个数](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer15-二进制中1的个数.playground/Contents.swift)\n\n[剑指 Offer 65. 不用加减乘除做加法](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer65-不用加减乘除做加法.playground/Contents.swift)\n\n#### 中等\n\n[剑指 Offer 56 - I. 数组中数字出现的次数](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer56-I-数组中数字出现的次数.playground/Contents.swift)\n\n[剑指 Offer 56 - II. 数组中数字出现的次数 II](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer56-II-数组中数字出现的次数%20II.playground/Contents.swift)\n\n### 数学\n\n#### 简单\n\n[剑指 Offer 39. 数组中出现次数超过一半的数字](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer39-数组中出现次数超过一半的数字.playground/Contents.swift)\n\n[剑指 Offer 57 - II. 和为s的连续正数序列](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer57II-和为s的连续正数序列.playground/Contents.swift)\n\n[剑指 Offer 62. 圆圈中最后剩下的数字](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer62-圆圈中最后剩下的数字.playground/Contents.swift)\n\n#### 中等\n\n[剑指 Offer 66. 构建乘积数组](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer66-构建乘积数组.playground/Contents.swift)\n\n[剑指 Offer 14- I. 剪绳子](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer14-I-剪绳子.playground/Contents.swift)\n\n[剑指 Offer 14- II. 剪绳子 II](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer14-II-剪绳子%20II.playground/Contents.swift)\n\n[剑指 Offer 44. 数字序列中某一位的数字](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer44-数字序列中某一位的数字.playground/Contents.swift)\n\n#### 困难\n\n[剑指 Offer 43. 1～n 整数中 1 出现的次数](https://github.com/HuangRunHua/leetcode-swift/tree/main/剑指Offer/剑指Offer43-1～n整数中1出现的次数.playground/Contents.swift)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuangrunhua%2Fleetcode-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuangrunhua%2Fleetcode-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuangrunhua%2Fleetcode-swift/lists"}