19. Case-specific Sorting of Strings
โ GFG solution to the Case-specific Sorting of Strings problem: sort uppercase and lowercase characters separately while maintaining their original positions. ๐
๐งฉ Problem Description
๐ Examples
Example 1
Input: s = "GEekS"
Output: EGekS
Explanation:
- Uppercase positions: 0(G), 1(E), 4(S) โ sorted: E, G, S
- Lowercase positions: 2(e), 3(k) โ sorted: e, k
- Result: EGekS (maintaining original case positions)Example 2
Input: s = "XWMSPQ"
Output: MPQSWX
Explanation: Since all characters are of the same case, we can simply perform a sorting operation on the entire string.๐ Constraints
โ
My Approach
Bitwise Optimized Frequency Counting
๐ Time and Auxiliary Space Complexity
๐งโ๐ป Code (C++)
โ Code (Java)
๐ Code (Python)
๐ง Contribution and Support
๐Visitor Count
Last updated