Flipkart Products Sort by Frequency
Flipkart Products Sort by Frequency
MediumSorting0% accepted
Flipkart sorts products by popularity. Given an integer array, sort by frequency in decreasing order. If two values have the same frequency, sort by value in increasing order.
Approach
Sort array by frequency descending; ties broken by value ascending.
Input
6
3 1 1 3 2 1
Output
1 1 1 3 3 2
More Sorting problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards