Skip to content

Commit 68e0771

Browse files
authored
Update README_EN.md
1 parent 66934b2 commit 68e0771

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

solution/1000-1099/1051.Height Checker/README_EN.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,7 @@ func heightChecker(heights []int) int {
142142
```ts
143143
function heightChecker(heights: number[]): number {
144144
const expected = [...heights].sort((a, b) => a - b);
145-
let ans = 0;
146-
147-
for (let i = 0; i < heights.length; i++) {
148-
if (expected[i] !== heights[i]) ans++;
149-
}
150-
151-
return ans;
145+
return heights.reduce((acc, cur, i) => acc + (cur !== expected[i] ? 1 : 0), 0);
152146
}
153147
```
154148

0 commit comments

Comments
 (0)