deno.land / x / masx200_leetcode_test@10.6.5 / license-key-formatting / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export default function licenseKeyFormatting(s: string, k: number): string { //@ts-ignore const str = s.replaceAll("-", "").toUpperCase();
return Array(Math.ceil(str.length / k)).fill(0).map((_, i) => i === 0 ? str.length % k ? str.slice(0, str.length % k) : str.slice(i * k, i * k + k) : str.length % k ? str.slice( -k + str.length % k + i * k, -k + str.length % k + i * k + k, ) : str.slice(i * k, i * k + k) ).join("-");}
masx200_leetcode_test

Version Info

Tagged at
a year ago