Question bank › Sorting
Dsa Sorting Medium

Classroom Seat Arrangement

You are tasked with arranging students in a classroom based on their height for a school photo. Given a list of student heights in centimeters, you need to sort them in ascending order while maintaining the integrity of their initial positions. If two students have the same height, the original order among them should be preserved. Input format: - The first line contains an integer N (1 <= N <= 1000), the number of students. - The second line contains N space-separated integers representing the heights of the students. Output format: - Print the heights in a single line, sorted in ascending order but maintaining the initial order for students of the same height. Example: Input: 5 150 160 150 170 160 Output: 150 150 160 160 170

Key concepts

sortinggreedyarrays

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.