Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Height Checker

XPChallenge Points: 10
levelLevel: Easy

A group of students should stand in a line sorted by height.
The sorted arrangement is called expected.
But right now, students are standing in the order given by heights.

Return how many positions in the current order differ from the expected sorted order.

Example 1:

Input: heights = [4,3,2,1]

Output: 4

Explanation:

expected = [1,2,3,4] All four positions are different.

Example 2:

Input: heights = [2,2,2]

Output: 0

Explanation:

expected = [2,2,2] No student is out of place.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result