Skip to content

Commit 2351bf7

Browse files
authored
Update Solution.js
1 parent 93d90bf commit 2351bf7

File tree

1 file changed

+9
-5
lines changed
  • solution/1500-1599/1509.Minimum Difference Between Largest and Smallest Value in Three Moves

1 file changed

+9
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
function minDifference(nums) {
2-
if (nums.length < 5) return 0;
1+
/**
2+
* @param {number[]} nums
3+
* @return {number}
4+
*/
5+
var minDifference = function (nums) {
6+
if (nums.length < 5) {
7+
return 0;
8+
}
39
nums.sort((a, b) => a - b);
410
let ans = Number.POSITIVE_INFINITY;
5-
611
for (let i = 0; i < 4; i++) {
712
ans = Math.min(ans, nums.at(i - 4) - nums[i]);
813
}
9-
1014
return ans;
11-
}
15+
};

0 commit comments

Comments
 (0)