Skip to content

Commit 95f20e6

Browse files
rain84idoocs
authored andcommitted
style: format code and docs with prettier
1 parent 1440ec4 commit 95f20e6

File tree

2 files changed

+68
-68
lines changed

2 files changed

+68
-68
lines changed

solution/2900-2999/2976.Minimum Cost to Convert String I/README.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -270,43 +270,43 @@ func minimumCost(source string, target string, original []byte, changed []byte,
270270

271271
```ts
272272
export function minimumCost(
273-
source: string,
274-
target: string,
275-
original: string[],
276-
changed: string[],
277-
cost: number[]
273+
source: string,
274+
target: string,
275+
original: string[],
276+
changed: string[],
277+
cost: number[],
278278
): number {
279-
const [n, m, MAX] = [source.length, original.length, Number.POSITIVE_INFINITY]
280-
const g: number[][] = Array.from({ length: 26 }, () => Array(26).fill(MAX))
281-
const getIndex = (ch: string) => ch.charCodeAt(0) - 'a'.charCodeAt(0)
282-
283-
for (let i = 0; i < 26; ++i) g[i][i] = 0
284-
for (let i = 0; i < m; ++i) {
285-
const x = getIndex(original[i])
286-
const y = getIndex(changed[i])
287-
const z = cost[i]
288-
g[x][y] = Math.min(g[x][y], z)
289-
}
290-
291-
for (let k = 0; k < 26; ++k) {
292-
for (let i = 0; i < 26; ++i) {
293-
for (let j = 0; g[i][k] < MAX && j < 26; j++) {
294-
if (g[k][j] < MAX) {
295-
g[i][j] = Math.min(g[i][j], g[i][k] + g[k][j])
279+
const [n, m, MAX] = [source.length, original.length, Number.POSITIVE_INFINITY];
280+
const g: number[][] = Array.from({ length: 26 }, () => Array(26).fill(MAX));
281+
const getIndex = (ch: string) => ch.charCodeAt(0) - 'a'.charCodeAt(0);
282+
283+
for (let i = 0; i < 26; ++i) g[i][i] = 0;
284+
for (let i = 0; i < m; ++i) {
285+
const x = getIndex(original[i]);
286+
const y = getIndex(changed[i]);
287+
const z = cost[i];
288+
g[x][y] = Math.min(g[x][y], z);
289+
}
290+
291+
for (let k = 0; k < 26; ++k) {
292+
for (let i = 0; i < 26; ++i) {
293+
for (let j = 0; g[i][k] < MAX && j < 26; j++) {
294+
if (g[k][j] < MAX) {
295+
g[i][j] = Math.min(g[i][j], g[i][k] + g[k][j]);
296+
}
297+
}
296298
}
297-
}
298299
}
299-
}
300-
301-
let ans = 0
302-
for (let i = 0; i < n; ++i) {
303-
const x = getIndex(source[i])
304-
const y = getIndex(target[i])
305-
if (x === y) continue
306-
if (g[x][y] === MAX) return -1
307-
ans += g[x][y]
308-
}
309-
return ans
300+
301+
let ans = 0;
302+
for (let i = 0; i < n; ++i) {
303+
const x = getIndex(source[i]);
304+
const y = getIndex(target[i]);
305+
if (x === y) continue;
306+
if (g[x][y] === MAX) return -1;
307+
ans += g[x][y];
308+
}
309+
return ans;
310310
}
311311
```
312312

solution/2900-2999/2976.Minimum Cost to Convert String I/README_EN.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -262,43 +262,43 @@ func minimumCost(source string, target string, original []byte, changed []byte,
262262

263263
```ts
264264
export function minimumCost(
265-
source: string,
266-
target: string,
267-
original: string[],
268-
changed: string[],
269-
cost: number[]
265+
source: string,
266+
target: string,
267+
original: string[],
268+
changed: string[],
269+
cost: number[],
270270
): number {
271-
const [n, m, MAX] = [source.length, original.length, Number.POSITIVE_INFINITY]
272-
const g: number[][] = Array.from({ length: 26 }, () => Array(26).fill(MAX))
273-
const getIndex = (ch: string) => ch.charCodeAt(0) - 'a'.charCodeAt(0)
274-
275-
for (let i = 0; i < 26; ++i) g[i][i] = 0
276-
for (let i = 0; i < m; ++i) {
277-
const x = getIndex(original[i])
278-
const y = getIndex(changed[i])
279-
const z = cost[i]
280-
g[x][y] = Math.min(g[x][y], z)
281-
}
282-
283-
for (let k = 0; k < 26; ++k) {
284-
for (let i = 0; i < 26; ++i) {
285-
for (let j = 0; g[i][k] < MAX && j < 26; j++) {
286-
if (g[k][j] < MAX) {
287-
g[i][j] = Math.min(g[i][j], g[i][k] + g[k][j])
271+
const [n, m, MAX] = [source.length, original.length, Number.POSITIVE_INFINITY];
272+
const g: number[][] = Array.from({ length: 26 }, () => Array(26).fill(MAX));
273+
const getIndex = (ch: string) => ch.charCodeAt(0) - 'a'.charCodeAt(0);
274+
275+
for (let i = 0; i < 26; ++i) g[i][i] = 0;
276+
for (let i = 0; i < m; ++i) {
277+
const x = getIndex(original[i]);
278+
const y = getIndex(changed[i]);
279+
const z = cost[i];
280+
g[x][y] = Math.min(g[x][y], z);
281+
}
282+
283+
for (let k = 0; k < 26; ++k) {
284+
for (let i = 0; i < 26; ++i) {
285+
for (let j = 0; g[i][k] < MAX && j < 26; j++) {
286+
if (g[k][j] < MAX) {
287+
g[i][j] = Math.min(g[i][j], g[i][k] + g[k][j]);
288+
}
289+
}
288290
}
289-
}
290291
}
291-
}
292-
293-
let ans = 0
294-
for (let i = 0; i < n; ++i) {
295-
const x = getIndex(source[i])
296-
const y = getIndex(target[i])
297-
if (x === y) continue
298-
if (g[x][y] === MAX) return -1
299-
ans += g[x][y]
300-
}
301-
return ans
292+
293+
let ans = 0;
294+
for (let i = 0; i < n; ++i) {
295+
const x = getIndex(source[i]);
296+
const y = getIndex(target[i]);
297+
if (x === y) continue;
298+
if (g[x][y] === MAX) return -1;
299+
ans += g[x][y];
300+
}
301+
return ans;
302302
}
303303
```
304304

0 commit comments

Comments
 (0)