Question: Language : C One night, Lili was staring at a collection of letters a - z lying on the table. At first Lili just moved

Language : C

One night, Lili was staring at a collection of letters a - z lying on the table. At first Lili just moved the letters randomly until the letters formed a square grid, then Lili thought of an interesting problem. Right now, Lili has a grid of letters that is R x C. Lili will do sorting 2 times. In the first sorting, Lili will sort the letters ascending lexicographically from left to right. In the second sorting, Lili will sort the words sorted before descending lexicographically. Example: dea efb gbe First ordering: ade bef beg Second Ordering: beg bef ade

Format Input : There are integers R and C in the first line. Then there are R lines, each of which contains C letters.

Format Output : Take out the R x C grid which is the sorted letter.

Constraints : 1 R, C 200

Sample Input (standard input) : 3 3 asj efd gza

Sample Output (standard output) : def ajs agz

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!