Solved LeetCode program · 992 of 1,000
#1370 · Increasing Decreasing String
Original English source
Keep a shared alphabet as empty text. Place "abcdefghijklmnopqrstuvwxyz" into alphabet. Keep a shared counts as an empty list of whole numbers.
For every letter from 0 to 25.
Place 0 into counts.
Keep a shared wanted as empty text. Keep a shared slot of 0. Keep a shared left of 0. Keep a shared line as empty text.
To rank. The spot is 0.
Repeat while spot is at most 25.
If the slice of alphabet from spot to spot plus 1 matches wanted, set slot to spot, return. Add 1 to spot.
The word is "aaaabbbbcccc". The last is the last position of word. Set left to last plus 1.
For every spot from 0 to last.
The symbol is the slice of word from spot to spot plus 1. Set wanted to symbol. Rank. The at is slot. Increase item at of counts by 1.
To lift.
For every letter from 0 to 25.
The many is item letter of counts.
If many is more than 0.
The symbol is the slice of alphabet from letter to letter plus 1. Place symbol into line. Set item letter of counts to many minus 1. Subtract 1 from left.
To lower.
For every step from 0 to 25.
The letter is 25 minus step. The many is item letter of counts.
If many is more than 0.
The symbol is the slice of alphabet from letter to letter plus 1. Place symbol into line. Set item letter of counts to many minus 1. Subtract 1 from left.
Repeat while left is more than 0.
Lift. Lower.
Show line.
Expected stdout
abccbaabccba