Unique sorting
Practice
4.3 (6 votes)
Algorithms
Greedy algorithms
Problem
66% Success 1395 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given a string \(s\) consisting of numeric digits (0-9) and Latin alphabetic characters ('a'-'z') only.
Your task is to sort the string but it must be sorted in a unique manner because here even characters or digits have higher priority than odd characters or digits. Although, as usual, other characters or digits have the same priority level. Also, digits have higher priority than characters.
For example, \('0'>'1',\ '0'>'5',\ 'a'>'b',\ '1'>'a',\ '3'>'1',\ 'd'>'b', and\ so\ on\).
Input format
- The first line contains \(t\) denoting the number of test cases.
- Each of the next \(t\) lines contains a string.
Output format
Print the sorted string for each test case.
Constraints
\(1 \le t \le 100\\
|s| \le 100\)
Submissions
Please login to view your submissions
Similar Problems
Points:10
8 votes
Tags:
Greedy AlgorithmsAlgorithmsBasics of Greedy AlgorithmsGreedy algorithm
Points:10
6 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsGreedy Algorithms
Points:10
11 votes
Tags:
HashingGreedy AlgorithmsBasics of Greedy AlgorithmsAlgorithms
Editorial