DSORT - Editorial

PROBLEM LINK:

Practice
Contest

Author: Shivam Pawase
Tester: Devansh Solanki
Editorialist: Sangram Desai

DIFFICULTY:

Easy

PREREQUISITES:

Strings, Sorting.

PROBLEM:

Given n integers, you have to print the numbers in descending order.

EXPLANATION:

Simply sorting the numbers won’t work as no of digits of a number can be upto 105 and max value of long long integer has only approximately 20 digits.

So you have to take input as string for every number and sort entire list first by length of numbers(as in string comparisons “200” is smaller than “50” since 2 < 5 as per ASCII) and if the length is same then that could be simply done by string sorting.

AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution can be found here.
Tester’s solution can be found here.

2 Likes