You are not logged in. Please login at www.codechef.com to post your questions!

×

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.

This question is marked "community wiki".

asked 09 Sep, 14:33

shmabulock's gravatar image

4★shmabulock
544
accept rate: 25%

edited 14 Sep, 18:10

admin's gravatar image

0★admin ♦♦
19.5k348496535

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×15,029
×3,469
×747
×38

question asked: 09 Sep, 14:33

question was seen: 493 times

last updated: 14 Sep, 18:10