{"id":19338889,"url":"https://github.com/yaliixxg/keep-doing-exercises","last_synced_at":"2026-05-14T22:01:48.950Z","repository":{"id":112254989,"uuid":"148242400","full_name":"YaliixxG/keep-doing-exercises","owner":"YaliixxG","description":"记录下自己做的题目。(Leetcode)","archived":false,"fork":false,"pushed_at":"2019-10-11T03:24:44.000Z","size":68,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-06T10:47:12.442Z","etag":null,"topics":["javascript","leetcode","python3","solutions"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/YaliixxG.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":"2018-09-11T01:29:08.000Z","updated_at":"2024-12-15T07:32:17.000Z","dependencies_parsed_at":"2023-05-12T01:45:40.346Z","dependency_job_id":null,"html_url":"https://github.com/YaliixxG/keep-doing-exercises","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/YaliixxG%2Fkeep-doing-exercises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YaliixxG%2Fkeep-doing-exercises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YaliixxG%2Fkeep-doing-exercises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YaliixxG%2Fkeep-doing-exercises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YaliixxG","download_url":"https://codeload.github.com/YaliixxG/keep-doing-exercises/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240441992,"owners_count":19801806,"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":["javascript","leetcode","python3","solutions"],"created_at":"2024-11-10T03:19:07.170Z","updated_at":"2026-05-14T22:01:43.902Z","avatar_url":"https://github.com/YaliixxG.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n * @Description: 记录\n * @Date: 2019-05-27 17:48:31\n * @LastEditTime: 2019-10-10 17:10:21\n --\u003e\n# keep-doing-exercises\n\n#### 记录下自己做的题目（以以下的题目序号和链接为准，主要用 javascript 和 python3 语言）。\n\n1. 给定一个整数数组和一个目标值，找出数组中和为目标值的两个数。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/1.two-sum.js)\n\n2. 给定一个 32 位有符号整数，将整数中的数字进行反转。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/7.reverse-integer.js)\n\n3. 判断一个整数是否是回文数。回文数是指正序（从左向右）和倒序（从右向左）读都是一样的整数（前提：不能转成字符串判断）。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/9.palindrome-number.js)\n\n4. 给定一个罗马数字，将其转换成整数。输入确保在 1  到 3999 的范围内。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/13.roman-to-integer.js)\n\n5. 给定一个只包括 '('，')'，'{'，'}'，'['，']'  的字符串，判断字符串是否有效,左右括号必须匹配。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/20.valid-parentheses.js)\n\n6. 编写一个函数来查找字符串数组中的最长公共前缀。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/14.longest-common-prefix.js)\n\n7. 给定一个排序数组，你需要在原地删除重复出现的元素，使得每个元素只出现一次，返回移除后数组的新长度。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/26.remove-duplicates-from-sorted-array.js)\n\n8. 给定一个数组 nums  和一个值 val，你需要原地移除所有数值等于  val  的元素，返回移除后数组的新长度。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/27.remove-element.js)\n\n9. 给定一个  haystack 字符串和一个 needle 字符串，在 haystack 字符串中找出 needle 字符串出现的第一个位置(从 0 开始)。如果不存在，则返回   -1。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/28.implement-strstr.js)\n\n10. 给定一个排序数组和一个目标值，在数组中找到目标值，并返回其索引。如果目标值不存在于数组中，返回它将会被按顺序插入的位置。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/35.search-insert-position.js)\n\n11. 给定一个正整数 n（1 ≤ n ≤ 30），输出报数序列的第 n 项。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/38.count-and-say.js)\n\n12. 给定一个整数数组 nums ，找到一个具有最大和的连续子数组（子数组最少包含一个元素），返回其最大和。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/53.maximum-subarray.js)\n\n13. 给定一个仅包含大小写字母和空格  ' '  的字符串，返回其最后一个单词的长度。如果不存在最后一个单词，请返回 0 。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/58.length-of-last-word.js)\n\n14. 给定一个由整数组成的非空数组所表示的非负整数，在该数的基础上加一。最高位数字存放在数组的首位， 数组中每个元素只存储一个数字。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/66.plus-one.js)\n\n15. 假设你正在爬楼梯。需要 n  阶你才能到达楼顶。每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢？[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/70.climbing-stairs.js)\n\n16. 给定两个二进制字符串，返回他们的和（用二进制表示）。输入为非空字符串且只包含数字  1  和  0。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/67.add-binary.js)\n\n17. 实现  int sqrt(int x)  函数。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/69.sqrtx.js)\n\n18. 给定两个有序整数数组  nums1 和 nums2，将 nums2 合并到  nums1  中，使得  num1 成为一个有序数组（注意：需改变原始数组方法）[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/88.merge-sorted-array.js)\n\n19. 给定一个非空整数数组，除了某个元素只出现一次以外，其余每个元素均出现两次。找出那个只出现了一次的元素。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/136.single-number.js)\n\n20. 给定一个非负整数  numRows，生成杨辉三角的前  numRows  行。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/118.pascals-triangle.js)\n\n21. 给定一个非负索引  k，其中 k ≤ 33，返回杨辉三角的第 k 行。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/119.pascals-triangle-ii.js)\n\n22. 给定一个数组，它的第  i 个元素是一支给定股票第 i 天的价格。如果你最多只允许完成一笔交易（即买入和卖出一支股票），设计一个算法来计算你所能获取的最大利润。注意你不能在买入股票前卖出股票。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/121.best-time-to-buy-and-sell-stock.js)\n\n23. 设计一个支持 push，pop，top 操作，并能在常数时间内检索到最小元素的栈。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/155.min-stack.js)\n\n24. 给定一个已按照升序排列的有序数组，找到两个数使得它们相加之和等于目标数。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/167.two-sum-ii-input-array-is-sorted.js)\n\n25. 给定一个正整数，返回它在 Excel 表中相对应的列名称。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/168.excel-sheet-column-title.js)\n\n26. 给定一个大小为 n 的数组，找到其中的众数。众数是指在数组中出现次数大于  ⌊ n/2 ⌋  的元素。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/169.majority-element.js)\n\n27. 给定一个整数 n，返回 n! 结果尾数中零的数量。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/172.factorial-trailing-zeroes.js)\n\n28. 编写一个算法来判断一个数是不是“快乐数”。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/202.happy-number.js)\n\n29. 统计所有小于非负整数  n  的质数的数量。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/204.count-primes.python3.py)\n\n30. 给定两个字符串  s  和  t，判断它们是否是同构的。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/205.isomorphic-strings.python3.py)\n\n31. 给定一个整数数组和一个整数  k，判断数组中是否存在两个不同的索引  i  和  j，使得  nums [i] = nums [j]，并且 i 和 j 的差的绝对值最大为 k。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/219.contains-duplicate-ii.py)\n\n32. 给定一个整数，编写一个函数来判断它是否是 2 的幂次方。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/231.power-of-two.js)\n\n33. 编写一个程序判断给定的数是否为丑数。丑数就是只包含质因数  2, 3, 5  的正整数。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/263.ugly-number.js)\n\n34. 给定一个包含 0, 1, 2, ..., n  中  n  个数的序列，找出 0 .. n  中没有出现在序列中的那个数。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/268.missing-number.js)\n\n35. 你和你的朋友，两个人一起玩  Nim 游戏：桌子上有一堆石头，每次你们轮流拿掉  1 - 3 块石头。 拿掉最后一块石头的人就是获胜者。你作为先手。你们是聪明人，每一步都是最优解。 编写一个函数，来判断你是否可以在给定石头数量的情况下赢得游戏。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/292.nim-game.js)\n\n36. 给定一个整数数组  nums，求出数组从索引  i  到  j  (i ≤ j) 范围内元素的总和，包含  i,  j  两点。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/303.range-sum-query-immutable.python3.py)\n\n37. 给定一个整数，写一个函数来判断它是否是 3  的幂次方。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/326.power-of-three.js)\n\n38. 给定一个整数，写一个函数来判断它是否是 4  的幂次方。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/342.power-of-four.js)\n\n39. 编写一个函数，其作用是将输入的字符串反转过来。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/344.reverse-string.python3.py)\n\n40. 给定两个数组，编写一个函数来计算它们的交集。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/349.intersection-of-two-arrays.python3.py)\n\n41. 输出结果中每个元素出现的次数，应与元素在两个数组中出现的次数一致。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/350.intersection-of-two-arrays-ii.python3.py)\n\n42. 给定一个正整数 num，编写一个函数，如果 num 是一个完全平方数，则返回 True，否则返回 False。不要使用任何内置的库函数，如   sqrt。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/367.valid-perfect-square.python3.py)\n\n43. 不使用运算符  + 和  - ​​​​​​​，计算两整数  ​​​​​​​a 、b ​​​​​​​ 之和。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/371.sum-of-two-integers.python3.py)\n\n44. 给定一个赎金信 (ransom)字符串和一个杂志(magazine)字符串，判断第一个字符串 ransom 能不能由第二个字符串 magazines 里面的字符构成。如果可以构成，返回 true ；否则返回 false。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/383.ransom-note.py)\n\n45. 给定一个字符串，找到它的第一个不重复的字符，并返回它的索引。如果不存在，则返回 -1。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/387.first-unique-character-in-a-string.js)\n\n46. 给定两个字符串 s 和 t，它们只包含小写字母。字符串  t  由字符串  s  随机重排，然后在随机位置添加一个字母。请找出在 t 中被添加的字母。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/389.find-the-difference.js)\n\n47. 给定一个非空数组，返回此数组中第三大的数。如果不存在，则返回数组中最大的数。要求算法时间复杂度必须是 O(n)。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/414.third-maximum-number.python3.py)\n\n48. 给定两个字符串形式的非负整数  num1 和 num2 ，计算它们的和。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/415.add-strings.python3.py)\n\n49. 给定一个范围在   1 ≤ a[i] ≤ n ( n = 数组大小 ) 的 整型数组，数组中的元素一些出现了两次，另一些只出现一次。找到所有在 [1, n] 范围之间没有出现在数组中的数字。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/448.find-all-numbers-disappeared-in-an-array.python3.py)\n\n50. 给定一个长度为 n 的非空整数数组，找到让数组所有元素相等的最小移动次数。每次移动可以使 n - 1 个元素增加 1。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/453.minimum-moves-to-equal-array-elements.python3.py)\n\n51. 假设你是一位很棒的家长，想要给你的孩子们一些小饼干。但是，每个孩子最多只能给一块饼干。对每个孩子 i ，都有一个胃口值  gi，这是能让孩子们满足胃口的饼干的最小尺寸；并且每块饼干 j ，都有一个尺寸 sj 。如果 sj \u003e= gi ，我们可以将这个饼干 j 分配给孩子 i，这个孩子会得到满足。你的目标是尽可能满足越多数量的孩子，并输出这个最大数值。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/455.assign-cookies.python3.py)\n\n52. 集合 S 包含从1到 n 的整数。不幸的是，因为数据错误，导致集合里面某一个元素复制了成了集合里面的另外一个元素的值，导致集合丢失了一个整数并且有一个元素重复。\n给定一个数组 nums 代表了集合 S 发生错误后的结果。你的任务是首先寻找到重复出现的整数，再找到丢失的整数，将它们以数组的形式返回。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/645.set-mismatch.js)  \n\n53. 不使用任何内建的哈希表库设计一个哈希集合。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/705.design-hashSet.js)  \n\n54. 编写一个程序，找到两个单链表相交的起始节点。[解答](https://github.com/YaliixxG/keep-doing-exercises/blob/master/160.intersection-of-two-linked-lists.js)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaliixxg%2Fkeep-doing-exercises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaliixxg%2Fkeep-doing-exercises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaliixxg%2Fkeep-doing-exercises/lists"}