Solved LeetCode program · 859 of 1,000
#1160 · Find Words That Can Be Formed by Characters
Original English source
The words is a list of "cat", "bt", "hat", and "tree". The available is "atach". The total is 0.
For each word in words.
The good is 1. The last is the last position of word.
For every spot from 0 to last.
The symbol is the slice of word from spot to spot plus 1. The needed is 0. The offered is 0. For every other from 0 to last, if the slice of word from other to other plus 1 matches symbol, add 1 to needed. For every other from 0 to the last position of available, if the slice of available from other to other plus 1 matches symbol, add 1 to offered. If needed is more than offered, set good to 0. If spot is last and good is 1, add (last plus 1) to total.
Show total.
Expected stdout
6