X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Sort the string in descending order
Basic Accuracy: 74.43% Submissions: 5715 Points: 1

Given a string str containing only lower case alphabets, the task is to sort it in lexicographically-descending order.

Example 1:

Input: str = "geeks"
Output: "skgee"
Explanation: It's the lexicographically-
descending order.

​Example 2:

Input: str = "for"
Output: "rof"
Explanation: "rof" is in
lexicographically-descending order.

Your Task:  
You don't need to read input or print anything. Your task is to complete the function ReverseSort() which takes the string str as inputs and returns the modified string.

Expected Time Complexity: O(|str|)
Expected Auxiliary Space: O(1)

Constraints:
1 ≤ |str| ≤ 105

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Sort the string in descending order

Output Window