I am designing a problem in which I want to find how many times a given string can be found (formed) from another base string with one character used only once.
Suppose I have
string str = "COMPUTER";
string basestr = "**TER** WITH **R** LABEL **COMPUTER** BELONGS TO **COMPUT** QUICK CUTE **COM** FOX JUM **P** S **U** R **T** H **E** LAZY DOG";
So want that my program returns 3 for this sting basestr.
Here one COMPUTER is clearly available, another is in two words and last is in words and characters.
Please help me program this ?
How can I do that ?
Thanks
First, construct character counts for the short string. Then construct character counts for the long string. For each character count of the short string, divide the count from the long string by the count of the short string, keeping only the integer part. Pick the smallest integer – it is the answer to your problem.