deno.land / x / masx200_leetcode_test@10.6.5 / distance-between-bus-stops / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { groupBy, sum } from "../deps.ts";
function distanceBetweenBusStops( distance: number[], start: number, destination: number,): number { [start, destination] = [ Math.min(start, destination), Math.max(start, destination), ];
return Math.min( // deno-lint-ignore ban-ts-comment //@ts-ignore ...Object.values( groupBy( Array.from(distance.entries()), ([index]) => start <= index && index < destination, ), // deno-lint-ignore ban-ts-comment //@ts-ignore ).map((value) => sum(value.map((a) => a[1]))), );}export default distanceBetweenBusStops;
masx200_leetcode_test

Version Info

Tagged at
a year ago