Skip to content

Commit f088672

Browse files
authored
Update README.md
1 parent 409a1da commit f088672

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.md

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

292292
#### JavaScript
293293

294-
```javascript
294+
```js
295295
const findLatestStep = function (arr, m) {
296-
let p = [];
297-
let size = [];
298-
299296
function find(x) {
300297
if (p[x] !== x) {
301298
p[x] = find(p[x]);
@@ -317,12 +314,9 @@ const findLatestStep = function (arr, m) {
317314
if (m === n) {
318315
return n;
319316
}
320-
const vis = new Array(n).fill(false);
321-
p = new Array(n);
322-
size = new Array(n).fill(1);
323-
for (let i = 0; i < n; ++i) {
324-
p[i] = i;
325-
}
317+
const vis = Array(n).fill(false);
318+
const p = Array.from({ length: n }, (_, i) => i);
319+
const size = Array(n).fill(1);
326320
let ans = -1;
327321
for (let i = 0; i < n; ++i) {
328322
const v = arr[i] - 1;

0 commit comments

Comments
 (0)