Top Coding Interview Question – Solved

5 Live
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 currentlylstanding in their correct positions. Example height = [1, 1, 3, 3, 4, 1] 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. Function Description Complete the function countStudents in the editor below. countStudents has the following parameter(s): 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. Constraints Β· 1≀n≀ 105

Asked in: No companies listed

Image of the Question

Question Image Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |