Leetcode Problem 1370. Increasing Decreasing String
1370. Increasing Decreasing String
Leetcode Solutions
Frequency Mapping Approach
Initialize a frequency array of size 26 to 0, representing the count of each character from 'a' to 'z'.
Iterate over the input string and increment the frequency of the corresponding character.
Initialize an empty result string.
While the length of the result string is less than the input string:
a. Append characters to the result string in ascending order of their ASCII values if their frequency is greater than 0.
b. Decrease the frequency of each character appended.
c. Append characters to the result string in descending order of their ASCII values if their frequency is greater than 0.
d. Decrease the frequency of each character appended.