Skip to content

Commit 409a1da

Browse files
authored
Update README_EN.md
1 parent 17b5e16 commit 409a1da

File tree

1 file changed

+4
-10
lines changed
  • solution/1500-1599/1562.Find Latest Group of Size M

1 file changed

+4
-10
lines changed

solution/1500-1599/1562.Find Latest Group of Size M/README_EN.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,8 @@ func findLatestStep(arr []int, m int) int {
271271

272272
#### JavaScript
273273

274-
```javascript
274+
```js
275275
const findLatestStep = function (arr, m) {
276-
let p = [];
277-
let size = [];
278-
279276
function find(x) {
280277
if (p[x] !== x) {
281278
p[x] = find(p[x]);
@@ -297,12 +294,9 @@ const findLatestStep = function (arr, m) {
297294
if (m === n) {
298295
return n;
299296
}
300-
const vis = new Array(n).fill(false);
301-
p = new Array(n);
302-
size = new Array(n).fill(1);
303-
for (let i = 0; i < n; ++i) {
304-
p[i] = i;
305-
}
297+
const vis = Array(n).fill(false);
298+
const p = Array.from({ length: n }, (_, i) => i);
299+
const size = Array(n).fill(1);
306300
let ans = -1;
307301
for (let i = 0; i < n; ++i) {
308302
const v = arr[i] - 1;

0 commit comments

Comments
 (0)