Given a string containing lowercase and uppercase letters.sort it in such a manner such that the uppercase and lowercase letter comes in an alternate manner but in sorted way.
Input : bAwutndekWEdkd Output :AbEdWddekkntuw Explanation: Here we can see that letter ‘A’, ’E’, ’W’ are sorted as well as letters “b, d, d, d, e, k, k, n, t, u, w” are sorted but both appears alternately in the string as far as possible. Input :abbfDDhGFBvdFDGBNDasZVDFjkb Output :BaBaDbDbDbDdDfFhFjFkGsGvNVZ
1) Count lower case characters in an array lCount
2) Count upper case characters in another array uCount
3) Modify string using lCount and uCount
Time Complexity : O(n)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Case conversion (Lower to Upper and Vice Versa) of a string using BitWise operators in C/C++
- Lower case to upper case - An interesting fact
- Comparison among Bubble Sort, Selection Sort and Insertion Sort
- Lower bound for comparison based sorting algorithms
- Minimum number of operations to move all uppercase characters before all lower case characters
- Number of flips to make binary string alternate | Set 1
- Minimum number of characters to be removed to make a binary string alternate
- Alternate vowel and consonant string
- Print the string by ignoring alternate occurrences of any character
- Lexicographically first alternate vowel and consonant string
- Rearrange a binary string as alternate x and y occurrences
- Check if it is possible to rearrange a binary string with alternate 0s and 1s
- Reverse alternate k characters in a string
- Why Quick Sort preferred for Arrays and Merge Sort for Linked Lists?
- Odd-Even Sort / Brick Sort
- Bucket Sort To Sort an Array with Negative Numbers
- Sort all even numbers in ascending order and then sort all odd numbers in descending order
- Serial Sort v/s Parallel Sort in Java
- Program to sort an array of strings using Selection Sort
- C/C++ Program for Odd-Even Sort / Brick Sort
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : parashar