Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit df18fe5

Browse files
authoredMay 26, 2019
Create 1051-height-checker.js
1 parent fac660d commit df18fe5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎1051-height-checker.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {number[]} heights
3+
* @return {number}
4+
*/
5+
const heightChecker = function(heights) {
6+
const arr = heights.slice(0).sort((a, b) => a - b)
7+
let res = 0
8+
for(let i = 0, len = heights.length; i < len; i++) {
9+
if(arr[i] !== heights[i]) res++
10+
}
11+
12+
return res
13+
};

0 commit comments

Comments
 (0)
Please sign in to comment.