2022-10-08-870-优势洗牌(田鸡赛马)

1 · zhuba-Ahhh · Oct. 8, 2022, 2:44 a.m.
870.优势洗牌(田鸡赛马)TS12345678910111213141516function advantageCount(nums1: number[], nums2: number[]): number[] { nums1 = nums1.sort((a, b) => a-b); const n2 = nums2.map((v, i) => [i, v]).sort((a,b) => a[1] - b[1]) let result = [], left = 0, right = nums1.length-1; for (let i = n2.length - 1; i >= 0; i--) { const cur2 = n2[i], cur1 = nums1[right]; if (cur1 > cur2[1]) { result[cur2[0]] = cur1; right--; } else { result[cur2[0]] = nums1[l...