deno.land / x / masx200_leetcode_test@10.6.5 / summary-ranges / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function summaryRanges(nums: number[]): string[] { const ans = Array<string>(); let last = nums[0]; let start = nums[0]; for (const i of nums.keys()) { const num = nums[i + 1]; if (num != last + 1) { if (last === start) { ans.push(String(last)); } else { ans.push([start, last].join("->")); } start = num; } last = num; } return ans;}export default summaryRanges;
masx200_leetcode_test

Version Info

Tagged at
a year ago