Question bank › Sorting
Dsa Sorting Hard

Stock Price Trends

You are analyzing stock prices over n days and wish to sort them based on the price drop percentage from the previous day. You must return the days in order of highest to lowest drop percentage. If two days have the same drop percentage, return them in order of their original position. Input: The first line contains an integer n (1 ≤ n ≤ 1000), the number of days. The second line contains n space-separated floats representing stock prices for those days. Output: Print the days ordered by drop percentage in the format 'Day X: Percentage'. The first day does not have a price drop. Example: Input: 5 100.0 90.0 80.0 85.0 75.0 Output: Day 2: 10.00% Day 3: 11.11% Day 5: 11.76% Day 4: 5.88%

Key concepts

sortingarrayscustom_sort

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.