FastPrepOrder Check (Backend)
Problems/Order Check (Backend)

Order Check (Backend)

Canva logoCanva● EasyINTERNOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Students in a class are asked to stand in ascending order according to their heights for the annual class photograph. Determine the number of students not currently standing in their correct positions.

Function

countStudents(height: int[]) → int

Complete the function countStudents in the editor.

countStudents has the following parameter(s):

  1. int height[n]: an array of heights in the order the students are standing

Returns int: the number of students not standing in the correct positions.

Examples

Example 1

height = [1, 1, 3, 3, 4, 1]return = 3

The 3 students indicated in red at indices 2, 4 and 5, are not in the right positions. The correct positions are [1, 1, 1, 3, 3, 4]. Return 3.

Example 2

height = [1, 1, 3, 4, 1]return = 3

The 3 students not standing in the correct position are at indices [2, 3, 4]. So, return 3. The currect positions are [1, 1, 1, 3, 4] :)

Constraints

  • 1 ≤ n ≤ 105
  • 1 <= height[i] <= 109

More Canva interview questions

  • Counting Binary Substrings (Backend)OA · Seen May 2026
  • Element SwappingOA · Seen Jul 2025
  • Women in STEM CharityOA · Seen Jul 2025
  • Character Reprogramming (Backend)OA · Seen Apr 2024

Similar questions at other companies

  • Count User Mentions in Chat MessagesRamp · OARamp interview questions
  • Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
  • Rank Football TeamsCapital One · OACapital One interview questions
  • Maximum Apples That Fit in a BoxVirtu Financial · OAVirtu Financial interview questions
  • Rank Football TeamsPersona · OAPersona interview questions
  • Meandering ArrayVerisk · OA
  • Minimum Magic Stones After MergesElevenLabs · OAElevenLabs interview questions
  • Find Top Two TeamsAutodesk · OAAutodesk interview questions
  • Total Server DowntimeVisa · OAVisa interview questions
All Canva interview questionsSee Canva hiring insights
Saved
class Solution {
    public int countStudents(int[] height) {
      // write your code here
    }

}
Checking account…