## The Problem:

How many strings equal to `A`

can be constructed using letters from the string `B`

? Each letter can be used only once and in one string only.

**Example**

For `A = "abc"`

and `B = "abccba"`

, the output should be

`stringsConstruction(A, B) = 2`

.

We can construct `2`

strings `A`

with letters from `B`

.

**Input/Output**

**[time limit] 4000ms (py)**

**[input] string A**String to construct,

`A`

contains only lowercase English letters.*Constraints:*

`3 ≤ A.length ≤ 10`

.**[input] string B**String containing needed letters,

`B`

contains only lowercase English letters.*Constraints:*

`3 ≤ B.length ≤ 50`

.**[output] integer**

## The Solution:

`def stringsConstruction(A, B):`

dA = {}

dB={}

for x in A:

dA[x]=dA.get(x,0)+1

for x in B:

dB[x]=dB.get(x,0)+1

minn = 9999

for x in A:

r = dB.get(x,0)/dA[x]

if r<minn:

minn=r

return minn

dA = {}

dB={}

for x in A:

dA[x]=dA.get(x,0)+1

for x in B:

dB[x]=dB.get(x,0)+1

minn = 9999

for x in A:

r = dB.get(x,0)/dA[x]

if r<minn:

minn=r

return minn

## The Explanation:

My way of solving is to use dictionaries, although we could easily do it with an array, too. The purpose of dictionaries is to keep track of the letters in the strings, “How many times letter ‘c’ is seen in string A?”, etc.