deno.land / x / masx200_leetcode_test@10.6.5 / compare-version-numbers / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
export default function compareVersion( version1: string, version2: string,): number { const a = version1.split(".").map(Number);
const b = version2.split(".").map(Number);
for (let i = 0; i < Math.max(a.length, b.length); i++) { const q = a[i] ?? 0;
const w = b[i] ?? 0;
if (q > w) return 1; if (q < w) return -1; } return 0;}
masx200_leetcode_test

Version Info

Tagged at
a year ago