deno.land / x / masx200_leetcode_test@10.6.5 / find-closest-lcci / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
export default function findClosest( words: string[], word1: string, word2: string,): number { let ans = words.length; let p1 = -Infinity; let p2 = -Infinity; for (const [i, word] of words.entries()) { if (word === word1) { p1 = i; } if (word === word2) { p2 = i; } if (p1 >= 0 && p2 >= 0) { ans = Math.min(ans, Math.abs(p1 - p2)); } } return ans;}
masx200_leetcode_test

Version Info

Tagged at
a year ago