Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/aizk/algorithm-practice
/ functions
Functions
147 in github.com/aizk/algorithm-practice
⨍
Functions
147
◇
Types & classes
25
↓ 7 callers
Function
exch
(a, i, j)
sort/quick/quick.py:101
↓ 6 callers
Function
TestVersionCompare
(v1, v2 string, expected int, expectedErr error)
string/版本号解析/main.go:18
↓ 5 callers
Function
ensure
(node *TreeNode, value int)
tree/0106-construct-binary-tree-from-inorder-and-postorder-traversal/main.go:44
↓ 5 callers
Function
ensure
(node *TreeNode, value int)
tree/0105-construct-binary-tree-from-preorder-and-inorder-traversal/main.go:43
↓ 4 callers
Function
TestReplaceBlank
(s string, expected string, expectedErr error)
string/replaceBlank/main.go:15
↓ 4 callers
Function
wrap
(partition)
sort/quick/quick.py:4
↓ 3 callers
Function
TestIsDeformation
(x, y string, expected bool)
string/isDeformation/main.go:11
↓ 3 callers
Function
max
(x, y int)
dp/0300/main.go:47
↓ 3 callers
Method
romanToInt
(self, s)
string/0013-roman-to-integer/main.py:2
↓ 2 callers
Function
binarySearch
(a, target)
search/binary-search/main.py:1
↓ 2 callers
Function
checkSymbol
(b byte)
string/版本号解析/main.go:87
↓ 2 callers
Function
compare
(x, y string)
string/版本号解析/main.go:62
↓ 2 callers
Method
getLeastNumbers
:type arr: List[int] :type k: int :rtype: List[int]
sort/quick/最小的 k 个数/main.py:2
↓ 2 callers
Function
hasTrue
(x, y bool)
dp/0416/0416.go:68
↓ 2 callers
Function
lengthOfLIS
给定一个无序的整数数组,找到其中最长上升子序列的长度。 输入: [10,9,2,5,3,7,101,18] 输出: 4 解释: 最长的上升子序列是 [2,3,7,101],它的长度是 4。 说明: 可能会有多种最长上升子序列的组合,你只需要输出对应的长度即可。 你算法的时间复杂度应该为 O(n
dp/0300/main.go:24
↓ 2 callers
Function
max
(i, j int)
dp/0343-integer-break/main.go:24
↓ 2 callers
Function
resolve
修改版 之前的写法太荣誉了,没想到可以写得如此简单... & 运算完之后的数字可以直接拿过来使用...
beauty-of-program/2.1 求二进制数中 1 的个数/main.go:26
↓ 2 callers
Function
romanToInt
罗马数字都是从大到小书写,也就是说不会出现 VX 这种 5 在 10 左边的情况,因此可以实现 逐个分析字符串的字符,根据规则递加得到结果 关键是抓住规律,并抽象出规律 先把每一位都加上,然后把要减去的减掉
leetcode/0013-roman-to-integer/main.go:24
↓ 1 callers
Function
CanPartition
(nums []int)
dp/0416/0416.go:7
↓ 1 callers
Function
DP
(n int)
dp/0811-coin-lcci/coin.go:43
↓ 1 callers
Function
FindTargetSumWays
暴力回溯提交会超出时间限制
dp/0494/0494.go:36
↓ 1 callers
Function
IsDeformation
互为变形词 长度不相等,直接 GG 长度相等,减少到 -1 也 GG
string/isDeformation/main.go:21
↓ 1 callers
Method
Pop
()
leetcode/0020-valid-parentheses/valid-parentheses.go:15
↓ 1 callers
Method
Push
(c rune)
leetcode/0020-valid-parentheses/valid-parentheses.go:11
↓ 1 callers
Function
RecursePrintList
(n *list.Node)
list/reverse-print-list/main.go:12
↓ 1 callers
Function
Recursive
(nums []int, S int)
dp/0494/0494.go:5
↓ 1 callers
Function
ReplaceBlank
(s string)
string/replaceBlank/main.go:24
↓ 1 callers
Function
SolveQueen
输入棋盘边长 N 返回所有合法的放置
back-track/n-queens/main.go:22
↓ 1 callers
Function
StrToInt
(s string, base int)
string/intToString/main.go:22
↓ 1 callers
Function
TestStrToInt
(s string, base int, expected int, expectedErr error)
string/intToString/main.go:12
↓ 1 callers
Function
VersionCompare
if v1 > v2 return 1 else v1 < v2 return -1 equal return 0
string/版本号解析/main.go:31
↓ 1 callers
Function
backtrack
(board *[]string, row int)
back-track/n-queens/main.go:35
↓ 1 callers
Function
backtrack
(nums []int, track *[]int)
back-track/full-permutation/full-permutation.go:15
↓ 1 callers
Function
buildTree
与 105 题类似
tree/0106-construct-binary-tree-from-inorder-and-postorder-traversal/main.go:52
↓ 1 callers
Function
buildTree
关键就是 preorder 的第一个元素是 root 节点 然后到 inorder 里面划分数组,子问题就出来了
tree/0105-construct-binary-tree-from-preorder-and-inorder-traversal/main.go:52
↓ 1 callers
Function
canClose
(s string)
leetcode/0020-valid-parentheses/valid-parentheses.go:45
↓ 1 callers
Function
change
(amount int, coins []int)
dp/0518-coin-change-2/main.go:10
↓ 1 callers
Function
coinChange
(coins []int, amount int)
dp/0322-coin-change/main.go:9
↓ 1 callers
Function
getPathNum
(path []int, x int)
tree/0129/m.go:74
↓ 1 callers
Function
helper
(nums *[]int, chosen *[]int, S int, count *int)
dp/0494/0494.go:46
↓ 1 callers
Function
helper
前序遍历
tree/0129/m.go:54
↓ 1 callers
Function
integerBreak
参考:https://mp.weixin.qq.com/s/ixnmuaj4lZJWj5jMMjnpWA 类似剪绳子 暴力递归
dp/0343-integer-break/main.go:34
↓ 1 callers
Function
isValid
(board *[]string, row int, col int)
back-track/n-queens/main.go:64
↓ 1 callers
Function
isValid
(s string)
leetcode/0020-valid-parentheses/valid-parentheses.go:23
↓ 1 callers
Method
isValid
:type s: str :rtype: bool
string/0020-valid-parentheses/main.py:2
↓ 1 callers
Function
levelOrder
:type root: TreeNode :rtype: List[List[int]]
tree/0102-binary-tree-level-order-traversal/s.py:8
↓ 1 callers
Function
levelOrder2
去除 newQueue
tree/traversal/level.go:36
↓ 1 callers
Function
merge
(l, r []int)
sort/merge/v1/merge.go:21
↓ 1 callers
Function
merge
(x, y []int, lx, ly int)
array/合并两个有序数组/main.go:14
↓ 1 callers
Function
mergeHelper
(array, newArray []int, left, right int)
sort/merge/merge.go:13
↓ 1 callers
Function
mergeTwoLists
** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ Merge two sorted linked lists and ret
leetcode/0021-merge-two-sorted-lists/main.go:47
↓ 1 callers
Function
min
(i, j int)
dp/0322-coin-change/main.go:28
↓ 1 callers
Function
minWindow
(s string, t string)
sliding-window/0076-minimum-window-substring/main.go:12
↓ 1 callers
Function
numJewelsInStones
J 里面的字符是珠宝 S 是一堆石头 判断 S 中珠宝的数量
leetcode/0771-jewels-and-stones/main.go:12
↓ 1 callers
Function
numUniqueEmails
(emails []string)
leetcode/0929-unique-email-addresses/main.go:9
↓ 1 callers
Function
partition
(a, s, e)
sort/quick/simple.py:5
↓ 1 callers
Function
partition
(a, s, e)
sort/quick/algo_4.py:4
↓ 1 callers
Function
partition
(a, s, e)
sort/quick/quick.py:14
↓ 1 callers
Method
partition
(self, arr, s, e)
sort/quick/最小的 k 个数/main.py:22
↓ 1 callers
Function
resolve2
--- 书上的解法 除 2 法
beauty-of-program/2.1 求二进制数中 1 的个数/main.go:37
↓ 1 callers
Function
reverse
反转整数 注意: - 正负号 - 最后一位 0
leetcode/0007-reverse-integer/main.go:17
↓ 1 callers
Method
reverse
(self, head, tail)
list/0025-reverse-nodes-in-k-group/main.py:37
↓ 1 callers
Function
search
(nums []int, target int)
array/0033-search-in-rotated-sorted-array/main.go:9
↓ 1 callers
Function
sort
这个方法空间复杂度不低(开辟很多新的数组),但是逻辑清晰 在 v2 中优化为只使用一个额外数组
sort/merge/v1/merge.go:13
↓ 1 callers
Function
sort
(a, s, e)
sort/quick/simple.py:28
↓ 1 callers
Function
sort
(a, s, e)
sort/quick/algo_4.py:30
↓ 1 callers
Function
sort
从 i、j 开始查找交换坑,直到 i == j 时 左边都是比 x 小的右边都是比 x 大的
sort/quick/quick.go:13
↓ 1 callers
Function
sumNumbers
(root *TreeNode)
tree/0129/m.go:39
↓ 1 callers
Function
twoSum
找到数组中两个数的和为 target
leetcode/0001-two-sum/main.go:10
↓ 1 callers
Function
uniquePaths
7 x 3
leetcode/0062-unique-paths/m.go:10
Method
Add
(v int)
list/list.go:25
Function
BinarySearch
二分查找
search/binary-search/main.go:4
Function
Force
需要考虑 <5、<10、<20 的边缘情况,此时 sum/M[3] == 0,会少一层循环
dp/0811-coin-lcci/coin.go:14
Function
NewList
return head
list/list.go:21
Method
Paint
()
list/list.go:33
Method
Remove
(v int)
list/list.go:29
Function
TestBFS
(t *testing.T)
tree/traversal/traversal_test.go:17
Function
TestCanPartition
(t *testing.T)
dp/0416/0416_test.go:5
Function
TestFindTargetSumWays
(t *testing.T)
dp/0494/0494_test.go:8
Function
addTwoNumbers
(l1 *ListNode, l2 *ListNode)
list/0002-add-two-numbers/main.go:12
Method
addTwoNumbers
(self, l1: ListNode, l2: ListNode)
list/0002-add-two-numbers/2.两数相加.py:14
Function
checkInclusion
(s1 string, s2 string)
sliding-window/0567-permutation-in-string/main.go:3
Method
getLeastNumbers
(self, arr: List[int], k: int)
sort/quick/最小的 k 个数/heap.py:6
Function
helper
(root *TreeNode, res *[]int)
tree/traversal/inorder.go:14
Function
init
()
list/list.go:13
Function
inorder
(root *TreeNode)
tree/traversal/inorder.go:9
Method
invertTree
:type root: TreeNode :rtype: TreeNode
tree/0226-invert-binary-tree/main.py:8
Function
isSameTree
(p *TreeNode, q *TreeNode)
tree/0100/main.go:49
Function
isValidBST
(root *TreeNode)
tree/0098/main.go:52
Function
lengthOfLongestSubstring
(s string)
sliding-window/0003-longest-substring-without-repeating-characters/main.go:7
Function
levelOrder
TODO 是否能不使用 newQueue 变量: for range 的过程中修改 slice 会怎样? 能够正常结束。循环内改变切片的长度,不影响循环次数,循环次效在循环开始前就已经确定了。
tree/traversal/level.go:7
Method
levelOrder
(self, root: TreeNode)
leetcode/102.二叉树的层序遍历.py:17
Function
lowestCommonAncestor
(root, p, q *TreeNode)
tree/235/main.go:53
Function
lowestCommonAncestor2
(root, p, q *TreeNode)
tree/235/main.go:72
Function
main
()
beauty-of-program/2.1 求二进制数中 1 的个数/main.go:5
Function
main
()
sliding-window/0076-minimum-window-substring/main.go:8
Function
main
()
sliding-window/0003-longest-substring-without-repeating-characters/main.go:3
Function
main
()
sort/merge/v1/merge.go:5
Function
main
()
sort/quick/quick.go:5
Function
main
()
sort/bubble/main.go:3
next →
1–100 of 147, ranked by callers