Tap here to switch tabs
Problem
Submissions

Problem: Height Checker

Height Checker compares students’ current height order with the nondecreasing order they should have and returns how many positions contain different heights.

Statement

A school is trying to arrange students in nondecreasing order of their heights. You are given an integer array heights representing the current order of the students.

Let expected be the array representing heights sorted in nondecreasing order.

Return the total number of indices i where heights[i] != expected[i].

Constraints:

  • 1≤1 \leq heights.length ≤100\leq 100

  • 1≤1 \leq heights[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Height Checker

Height Checker compares students’ current height order with the nondecreasing order they should have and returns how many positions contain different heights.

Statement

A school is trying to arrange students in nondecreasing order of their heights. You are given an integer array heights representing the current order of the students.

Let expected be the array representing heights sorted in nondecreasing order.

Return the total number of indices i where heights[i] != expected[i].

Constraints:

  • 1≤1 \leq heights.length ≤100\leq 100

  • 1≤1 \leq heights[i] ≤100\leq 100