Back to course home
0% completed
Solution: Height Checker
Problem Statement
A school is organizing its annual photo session, and students must stand in a single line arranged by height in non-decreasing order. The expected order of heights is represented by an array expected
, where expected[i]
is the height of the i<sup>th</sup> student in line.
Given an array heights
representing the current order in which students are standing, determine how many positions in the heights
array do not match the expected
order.
Examples
- Example 1:
- Input: heights =
[5, 1, 2, 3, 4, 8, 1]
- Expected Output:
3
- Input: heights =
.....
.....
.....
Like the course? Get enrolled and start learning!