Solved LeetCode program · 864 of 1,000
#1170 · Compare Strings by Frequency of the Smallest Character
Original English source
Keep a shared current as empty text. Keep a shared weight of 0.
To weigh. The ordered is sort characters of current. The smallest is character 0 of ordered. The total is 0. For every spot from 0 to the last position of ordered, if character spot of ordered is smallest, add 1 to total. Set weight to total.
The queries is a list of "bbb", and "cc". The words is a list of "a", "aa", "aaa", and "aaaa". The wordlast is the last position of words.
For each query in queries.
Set current to a copy of query. Weigh. The wanted is weight. The total is 0.
For every which from 0 to wordlast.
Set current to item which of words. Weigh. If weight is more than wanted, add 1 to total. If which is wordlast, Show total.
Expected stdout
1 2