Skip to content

Update dependencies #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion 2vYnGI/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function breakfastNumber(
staple: number[],
drinks: number[],
x: number
x: number,
): number {
staple.sort((a, b) => a - b);
drinks.sort((a, b) => a - b);
Expand Down
2 changes: 1 addition & 1 deletion 3sum-closest/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function threeSumClosest(
nums: number[],
target: number
target: number,
): number {
const N = nums.length;
let res = Number.MAX_SAFE_INTEGER;
Expand Down
4 changes: 2 additions & 2 deletions 4sum/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ function fourSum(nums: number[], target: number): number[][] {
let left: number = j + 1;
let right: number = nums.length - 1;
while (left < right) {
const res: number =
nums[i] + nums[j] + nums[left] + nums[right];
const res: number = nums[i] + nums[j] + nums[left] +
nums[right];
if (res > target) {
right--;
} else if (res < target) {
Expand Down
2 changes: 1 addition & 1 deletion 4ueAj6/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ListNode as Node } from "../reverse-linked-list/ListNode.ts";

export default function insert(
head: Node | null,
insertVal: number
insertVal: number,
): Node | null {
if (!head) {
const node = new Node(insertVal);
Expand Down
6 changes: 3 additions & 3 deletions FJxjiD/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ export default function chickenCoolRun(paths: number[][]): number {
temp[1] = Math.min(
temp[1],
temp[0] < Infinity ? temp[0] + 1 : Infinity,
temp[2] < Infinity ? temp[2] + 1 : Infinity
temp[2] < Infinity ? temp[2] + 1 : Infinity,
);

temp[0] = Math.min(
temp[0],
paths[0][j] === 0 ? temp[1] + 1 : Infinity
paths[0][j] === 0 ? temp[1] + 1 : Infinity,
);
temp[2] = Math.min(
temp[2],
paths[2][j] === 0 ? temp[1] + 1 : Infinity
paths[2][j] === 0 ? temp[1] + 1 : Infinity,
);
}

Expand Down
2 changes: 1 addition & 1 deletion Jf1JuT/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function createEdgesAndIndegrees(words: string[]): {
function topologicalsort(
edges: Map<string, Set<string>>,
indegrees: Map<string, number>,
chars: Set<string>
chars: Set<string>,
): string[] {
const order: string[] = [];

Expand Down
14 changes: 7 additions & 7 deletions KnLfVT/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { TreeNode } from "../binary-tree-inorder-traversal/TreeNode.ts";

export default function expandBinaryTree(
root: TreeNode | null
root: TreeNode | null,
): TreeNode | null {
return root
? new TreeNode(
root.val,
root.left ? new TreeNode(-1, expandBinaryTree(root.left)) : null,
root.right
? new TreeNode(-1, null, expandBinaryTree(root.right))
: null
)
root.val,
root.left ? new TreeNode(-1, expandBinaryTree(root.left)) : null,
root.right
? new TreeNode(-1, null, expandBinaryTree(root.right))
: null,
)
: null;
}
4 changes: 2 additions & 2 deletions NyZD2B/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class VendingMachine {
number: number,
item: string,
price: number,
duration: number
duration: number,
): void {
const good = this.#item2good.get(item) ?? [
new AvlTree((a, b) =>
Expand Down Expand Up @@ -71,7 +71,7 @@ class VendingMachine {
cost += value.price * diff;
}
},
signal
signal,
);

toBeRemoved.forEach((n) => tree.remove(n));
Expand Down
2 changes: 1 addition & 1 deletion QO5KpG/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { lowerBound } from "../number-of-pairs-satisfying-inequality/lowerBound.

export default function getNumber(
root: TreeNode | null,
ops: number[][]
ops: number[][],
): number {
const sorted = inorderTraversal(root);
let ans = 0;
Expand Down
14 changes: 7 additions & 7 deletions U7WvvU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function closeLampInTree(root: TreeNode | null): number {
open + 1,
close + 1,
self + 3,
notSelf + 1
notSelf + 1,
);
}

Expand All @@ -41,15 +41,15 @@ export default function closeLampInTree(root: TreeNode | null): number {
open + 1,
close + 1,
self + 1,
notSelf + 3
notSelf + 3,
);
} else {
allClose = Math.min(
allClose,
open + 2,
close,
self + 2,
notSelf + 2
notSelf + 2,
);
}

Expand All @@ -60,7 +60,7 @@ export default function closeLampInTree(root: TreeNode | null): number {
open + 2,
close,
self + 2,
notSelf + 2
notSelf + 2,
);
} else {
// 关着
Expand All @@ -69,7 +69,7 @@ export default function closeLampInTree(root: TreeNode | null): number {
open + 1,
close + 1,
self + 1,
notSelf + 3
notSelf + 3,
);
}

Expand All @@ -81,15 +81,15 @@ export default function closeLampInTree(root: TreeNode | null): number {
open + 1,
close + 1,
self + 3,
notSelf + 1
notSelf + 1,
);
} else {
justNotSelf = Math.min(
justNotSelf,
open,
close + 2,
self + 2,
notSelf + 2
notSelf + 2,
);
}

Expand Down
2 changes: 1 addition & 1 deletion ZbAuEH/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getMaximumNumber(moles: number[][]): number {
for (let cnt = 0, j = i - 1; cnt < 10 && j >= 0; j--, cnt++) {
if (
Math.abs(x - moles[j][1]) + Math.abs(y - moles[j][2]) <=
t - moles[j][0]
t - moles[j][0]
) {
dp[i][1] = Math.max(dp[i][1], dp[j][1] + 1);
}
Expand Down
3 changes: 1 addition & 2 deletions add-binary/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ export default function addBinary(num1: string, num2: string): string {
let carry = 0;
for (let i = 0; i < Math.max(num2.length, num1.length); i++) {
// console.log(i, num1[i], num2[i], carry);
const r =
carry +
const r = carry +
Number(getIntegerReverse(num1, i)) +
Number(getIntegerReverse(num2, i));
result.push(r % 2);
Expand Down
6 changes: 3 additions & 3 deletions add-one-row-to-tree/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TreeNode } from "../mod.ts";
export default function addOneRow(
root: TreeNode | null,
val: number,
depth: number
depth: number,
): TreeNode | null {
if (!root || !depth) return null;

Expand All @@ -13,13 +13,13 @@ export default function addOneRow(
return new TreeNode(
root.val,
new TreeNode(val, root.left),
new TreeNode(val, null, root.right)
new TreeNode(val, null, root.right),
);
}

return new TreeNode(
root.val,
addOneRow(root.left, val, depth - 1),
addOneRow(root.right, val, depth - 1)
addOneRow(root.right, val, depth - 1),
);
}
2 changes: 1 addition & 1 deletion add-two-numbers-ii/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ListNode } from "../mod.ts";

export default function addTwoNumbers(
l1: ListNode | null,
l2: ListNode | null
l2: ListNode | null,
): ListNode | null {
if (!l1) {
return l2;
Expand Down
2 changes: 1 addition & 1 deletion add-two-polynomials-represented-as-linked-lists/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PolyNode } from "./PolyNode.ts";

export default function addPoly(
poly1: PolyNode | null,
poly2: PolyNode | null
poly2: PolyNode | null,
): PolyNode | null {
const dummy = new PolyNode();
let node = dummy;
Expand Down
2 changes: 1 addition & 1 deletion adding-two-negabinary-numbers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function addNegabinary(
arr1: number[],
arr2: number[]
arr2: number[],
): number[] {
const len = Math.max(arr1.length, arr2.length);
arr1 = arr1.reverse();
Expand Down
2 changes: 1 addition & 1 deletion advantage-shuffle/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function advantageCount(
nums1: number[],
nums2: number[]
nums2: number[],
): number[] {
const n = nums1.length;
const idx1: number[] = new Array(n).fill(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function alertNames(
keyName: string[],
keyTime: string[]
keyTime: string[],
): string[] {
const map = new Map<string, number[]>();

Expand All @@ -21,7 +21,7 @@ export default function alertNames(
v.length >= 3 &&
v
.sort((a, b) => a - b)
.some((n, i, a) => i + 2 < a.length && 60 >= a[i + 2] - n)
.some((n, i, a) => i + 2 < a.length && 60 >= a[i + 2] - n),
)
.map((a) => a[0])
.sort();
Expand Down
2 changes: 1 addition & 1 deletion all-elements-in-two-binary-search-trees/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { merge_sort } from "./merge_sort.ts";

export default function getAllElements(
root1: TreeNode | null,
root2: TreeNode | null
root2: TreeNode | null,
): number[] {
const nums1: number[] = [];
const nums2: number[] = [];
Expand Down
2 changes: 1 addition & 1 deletion all-paths-from-source-to-target/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function dfs(
graph: number[][],
res: number[][],
index: number,
path: number[]
path: number[],
) {
if (index === graph.length - 1) {
res.push(Array.from(path));
Expand Down
2 changes: 1 addition & 1 deletion apply-discount-to-prices/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function discountPrices(
sentence: string,
discount: number
discount: number,
): string {
return sentence
.split(" ")
Expand Down
2 changes: 1 addition & 1 deletion armstrong-number/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default function isArmstrong(n: number) {
return (
[...n.toString()].reduce(
(p, v, _i, a) => p + Math.pow(Number(v), a.length),
0
0,
) === n
);
}
22 changes: 11 additions & 11 deletions assign-cookies/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
function findContentChildren(g: number[], s: number[]): number {
g = g.sort((a, b) => a - b)
s = s.sort((a, b) => a - b)
let result = 0
let index = s.length - 1
for(let i = g.length - 1; i >= 0; i--) {
if(index >= 0 && s[index] >= g[i]) {
result++
index--
g = g.sort((a, b) => a - b);
s = s.sort((a, b) => a - b);
let result = 0;
let index = s.length - 1;
for (let i = g.length - 1; i >= 0; i--) {
if (index >= 0 && s[index] >= g[i]) {
result++;
index--;
}
}
return result
}
return result;
}
export default findContentChildren
export default findContentChildren;
2 changes: 1 addition & 1 deletion average-of-levels-in-binary-tree/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ function level(nodes: TreeNode[], output: (r: number) => void) {
nodes
.map((n) => [n.left, n.right].filter(Boolean) as TreeNode[])
.flat(),
output
output,
);
}
2 changes: 1 addition & 1 deletion basic-calculator-iv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { tokenize } from "./tokenize.ts";
export default function basicCalculatorIV(
expression: string,
evalvars: string[],
evalints: number[]
evalints: number[],
): string[] {
const tokens = tokenize(expression, evalvars, evalints);
return parse(tokens).toList();
Expand Down
17 changes: 16 additions & 1 deletion beautiful-arrangement/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,20 @@ export default function countArrangement(n: number): number {
return cache[n] ?? 0;
}
const cache = [
0, 1, 2, 3, 8, 10, 36, 41, 132, 250, 700, 750, 4010, 4237, 10680, 24679,
0,
1,
2,
3,
8,
10,
36,
41,
132,
250,
700,
750,
4010,
4237,
10680,
24679,
];
7 changes: 4 additions & 3 deletions best-time-to-buy-and-sell-stock-iv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ function maxProfit(k: number, prices: number[]): number {
return 0;
}

const dp: number[][] = Array.from(Array(prices.length), () =>
Array(2 * k + 1).fill(0)
const dp: number[][] = Array.from(
Array(prices.length),
() => Array(2 * k + 1).fill(0),
);

for (let j = 1; j < 2 * k; j += 2) {
Expand All @@ -16,7 +17,7 @@ function maxProfit(k: number, prices: number[]): number {
dp[i][j + 1] = Math.max(dp[i - 1][j + 1], dp[i - 1][j] - prices[i]);
dp[i][j + 2] = Math.max(
dp[i - 1][j + 2],
dp[i - 1][j + 1] + prices[i]
dp[i - 1][j + 1] + prices[i],
);
}
}
Expand Down
Loading