Skip to content

Commit e556f76

Browse files
committed
added function
1 parent 9698c87 commit e556f76

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Height Checker/code.js

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

0 commit comments

Comments
 (0)