MCPcopy Create free account

hub / github.com/PinkyJie/leetcode-patterns / functions

Functions252 in github.com/PinkyJie/leetcode-patterns

↓ 1 callersFunction_splitAndCombine
(expression, memo)
17_divide-and-conquer/241_different-ways-to-add-parentheses.js:44
↓ 1 callersFunction_swap
(array, i, j)
5_cyclic-sort/41_first-smallest-missing-positive.js:49
↓ 1 callersFunction_swap
(array, i, j)
5_cyclic-sort/442_find-all-duplicates-in-an-array.js:48
↓ 1 callersFunction_swap
(array, i, j)
5_cyclic-sort/448_find-all-numbers-disappeared-in-an-array.js:46
↓ 1 callersFunction_swap
(array, i, j)
5_cyclic-sort/0_find-the-corrupt-pair.js:56
↓ 1 callersFunction_swap
(array, i, j)
5_cyclic-sort/0_find-first-k-missing-positive-numbers.js:75
↓ 1 callersFunction_swap
(array, i, j)
5_cyclic-sort/268_missing-number.js:46
↓ 1 callersFunction_swap
(array, i, j)
5_cyclic-sort/0_cyclic-sort.js:38
↓ 1 callersFunction_swap
(array, i, j)
5_cyclic-sort/287_find-the-duplicate-number.js:40
↓ 1 callersFunction_traverse
(node, sequence, curIndex)
8_DFS/1430_check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree.js:33
↓ 1 callersFunction_traverse
(node)
8_DFS/543_diameter-of-binary-tree.js:39
↓ 1 callersFunction_traverse
(node)
8_DFS/124_binary-tree-maximum-path-sum.js:37
↓ 1 callersFunction_traverse
(node, sum, curPath)
8_DFS/437_path-sum-iii.js:34
↓ 1 callersFunction_traverse
(node, targetSum, curPath, result)
8_DFS/113_path-sum-ii.js:33
↓ 1 callersFunction_traverse
(node, curSum)
8_DFS/129_sum-root-to-leaf-numbers.js:32
↓ 1 callersFunction_traverse
(nodes, result)
7_BFS/107_binary-tree-level-order-traversal-ii.js:68
↓ 1 callersFunctioncanPartitionToEqualSum2
* * Solution 2: top-down dynamic programming with memoization. * * @param {number[]} nums * @return {boolean}
15_dynamic-programming/416_partition-equal-subset-sum.js:94
↓ 1 callersFunctioncanPartitionToEqualSum3
* * Solution 3: bottom-up dynamic programming. * * Time: O(mn) m: target sum <- loop to populate `dp` * Space: O(mn) <- for the `dp` * * @param
15_dynamic-programming/416_partition-equal-subset-sum.js:137
↓ 1 callersFunctioncanPartitionToEqualSum4
* * Solution 4: bottom-up dynamic programming with reduced space. * * Time: O(mn) m: target sum <- loop to populate `dp` * Space: O(m) <- for the
15_dynamic-programming/416_partition-equal-subset-sum.js:179
↓ 1 callersFunctionconnectLevelNodeSiblingForPerfectBinaryTree
* If the tree is a perfect binary tree (where each node must have 2 children expect * the leaf nodes), the above solution can be simplified further.
7_BFS/116_populating-next-right-pointers-in-each-node.js:89
↓ 1 callersFunctionconnectLevelNodeSiblingWithConstantSpace
* O(1) space solution which does not require storing all level nodes.
7_BFS/116_populating-next-right-pointers-in-each-node.js:49
↓ 1 callersFunctioncountOfNumbersLessOrEqualThan
* * Give a number `target`, find out how many numbers in the matrix are less than * or equal to `target`. * * Time: O(n) * * @param {number[][]}
14_k-way-merge/378_kth-smallest-element-in-a-sorted-matrix.js:132
↓ 1 callersFunctioncountUniqueBST2
* A more simplified solution: the tricky part is to understand the count * of [i + 1, n] can be treated as the same count of [1, n - (i + 1) + 1]. *
17_divide-and-conquer/96_unique-binary-search-trees.js:69
↓ 1 callersFunctioncountUniqueBST3
* A non-recursive version based on countUniqueBST2() above. * Time: O(n^2)
17_divide-and-conquer/96_unique-binary-search-trees.js:87
↓ 1 callersFunctionfindSubsetsBacktrack
* A more general solution with backtracking, if we think the whole process as * a tree, the constructing of the subsets is like DFS of the tree. *
10_subsets/78_subsets.js:79
↓ 1 callersFunctionknapsack1
* * Solution 1: recursive brute-force way. * * @param {number[]} weights * @param {number[]} profits * @param {number} capacity * @return {numbe
15_dynamic-programming/0_0-1-knapsack.js:30
↓ 1 callersFunctionknapsack2
* * Solution 2: recursion with memoization, also called top-down dynamic programming * with memoization. * * Why we call it "top-down", because wh
15_dynamic-programming/0_0-1-knapsack.js:106
↓ 1 callersFunctionknapsack3
* * Solution 3: bottom-up dynamic programming. * Similar as "Solution 2" above, we still want to calculate all the possible combinations * of `inde
15_dynamic-programming/0_0-1-knapsack.js:177
↓ 1 callersFunctionknapsack4
* * Solution 4: bottom-up dynamic programming with reduced space. * Similar as "Solution 3" above, but if we look the transition function we get *
15_dynamic-programming/0_0-1-knapsack.js:247
↓ 1 callersFunctionkthSmallestNumberInSortedMatrixWithBinarySearch
* * Another solution with binary search. * Binary search requires the search space is sorted, how does this row/col-based * matrix achieve this? Th
14_k-way-merge/378_kth-smallest-element-in-a-sorted-matrix.js:90
↓ 1 callersFunctionkthSmallestNumberInSortedMatrixWithHeap
* * Problem: * Given an N * N matrix where each row and column is sorted in ascending order, find * the Kth smallest element in the matrix. * http
14_k-way-merge/378_kth-smallest-element-in-a-sorted-matrix.js:27
↓ 1 callersFunctionmaximizeCapital
* * Problem: * Given a set of investment projects with their respective profits, we need to find * the most profitable projects. We are given an in
9_two-heaps/502_ipo.js:48
↓ 1 callersFunctionreorderLinkedList
* * Problem: * Given the head of a Singly LinkedList, write a method to modify the LinkedList * such that the nodes from the second half of the Lin
3_fast-slow-pointers/143_reorder-list.js:29
↓ 1 callersFunctionreverseLinkedList
* * Problem: * Given the head of a Singly LinkedList, reverse the LinkedList. Write a function to * return the new head of the reversed LinkedList.
6_in-place-reversal-of-a-linked-list/206_reverse-linked-list.js:17
↓ 1 callersFunctionreverseLinkedListRecursively
* Do the reversion in the recursive manner.
6_in-place-reversal-of-a-linked-list/206_reverse-linked-list.js:32
↓ 1 callersFunctionreverseSubLinkedList
* * Problem: * Given the head of a LinkedList and two positions "p" and "q" (1-based), reverse the * LinkedList from position "p" to "q". * https:
6_in-place-reversal-of-a-linked-list/92_reverse-linked-list-ii.js:19
FunctionListNode
(val)
_utils.js:139
FunctionMedianOfAStream
()
9_two-heaps/295_find-median-from-data-stream.js:28
FunctionTreeNode
(val)
_utils.js:165
Method_debug
()
_utils.js:21
Methodconstructor
(comparator, array = [])
_utils.js:2
Methodconstructor
(arr)
11_binary-search/702_search-in-a-sorted-array-of-unknown-size.js:66
Methodconstructor
* * Time: O(n log(n)) * Space: O(k) * * @param {number} k * @param {number[]} nums
13_top-k-elements/703_kth-largest-element-in-a-stream.js:30
Methodconstructor
* It's intuitive to use heap here, because for each pop() we need to get the highest * frequency number quickly, which means for each push() we sho
13_top-k-elements/895_maximum-frequency-stack.js:39
Methodconstructor
* Not that intuitive but more efficient solution. Besides the frequency map (key is * number and value is the frequency), we also maintain another
13_top-k-elements/895_maximum-frequency-stack.js:106
FunctionfindUniqueBSTBacktrack
(n)
17_divide-and-conquer/95_unique-binary-search-trees-ii.js:108
Methodpop
* * Time: O(1) * * @return {number}
13_top-k-elements/895_maximum-frequency-stack.js:137
FunctionprintTreeBFS
(root)
_utils.js:191
Methodpush
* * Time: O(1) * * @param {number} num * @return void
13_top-k-elements/895_maximum-frequency-stack.js:122
FunctionsmallEndPriorityComparator
(a, b)
4_merge-intervals/253_meeting-rooms-ii.js:44
FunctionsmallEndPriorityComparator
(a, b)
4_merge-intervals/0_maximum-cpu-load.js:37
FunctionsmallStartPriorityComparator
(a, b)
4_merge-intervals/759_employee-free-time.js:52
← previous201–252 of 252, ranked by callers