/*
* @lc app=leetcode.cn id=2465 lang=typescript
*
* [2465] 不同的平均值数目
*/
// @lc code=start
function distinctAverages(nums: number[]): number {}
// @lc code=end
function distinctAverages(nums: number[]): number {
const set = new Set<number>()
nums.sort((a, b) => a - b)
const n = nums.length
for (let i = 0, j = n - 1; i <= j; i++, j--) {
set.add((nums[i] + nums[j]) / 2)
}
return set.size
}
test.each([
{ input: { nums: [4, 1, 4, 0, 3, 5] }, output: 2 },
{ input: { nums: [1, 100] }, output: 1 },
])('input: nums = $input.nums', ({ input: { nums }, output }) => {
expect(distinctAverages(nums)).toEqual(output)
})