Skip to content

Commit 7797047

Browse files
authored
Update README_EN.md
1 parent dd9723a commit 7797047

File tree

1 file changed

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

1 file changed

+15
-11
lines changed

solution/1500-1599/1509.Minimum Difference Between Largest and Smallest Value in Three Moves/README_EN.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,32 +160,36 @@ func minDifference(nums []int) int {
160160

161161
```ts
162162
function minDifference(nums: number[]): number {
163-
if (nums.length < 5) return 0;
163+
if (nums.length < 5) {
164+
return 0;
165+
}
164166
nums.sort((a, b) => a - b);
165-
let res = Number.POSITIVE_INFINITY;
166-
167+
let ans = Number.POSITIVE_INFINITY;
167168
for (let i = 0; i < 4; i++) {
168-
res = Math.min(res, nums.at(i - 4)! - nums[i]);
169+
ans = Math.min(ans, nums.at(i - 4)! - nums[i]);
169170
}
170-
171-
return res;
171+
return ans;
172172
}
173173
```
174174

175175
#### JavaScript
176176

177177
```js
178-
function minDifference(nums) {
179-
if (nums.length < 5) return 0;
178+
/**
179+
* @param {number[]} nums
180+
* @return {number}
181+
*/
182+
var minDifference = function (nums) {
183+
if (nums.length < 5) {
184+
return 0;
185+
}
180186
nums.sort((a, b) => a - b);
181187
let ans = Number.POSITIVE_INFINITY;
182-
183188
for (let i = 0; i < 4; i++) {
184189
ans = Math.min(ans, nums.at(i - 4) - nums[i]);
185190
}
186-
187191
return ans;
188-
}
192+
};
189193
```
190194

191195
<!-- tabs:end -->

0 commit comments

Comments
 (0)