MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / height_checker

Function height_checker

1051-height-checker.rs:14–24  ·  view source on GitHub ↗
(heights: Vec<i32>)

Source from the content-addressed store, hash-verified

12// 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
13
14pub fn height_checker(heights: Vec<i32>) -> i32 {
15 let mut res = 0;
16 let mut sorted_heights = heights.clone();
17 sorted_heights.sort();
18 for (i, h) in heights.into_iter().enumerate() {
19 if h != sorted_heights[i] {
20 res += 1;
21 }
22 }
23 res
24}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected