Longest common subsequence by allowing re arrangement of common parts
Assume we have to char stream like:

    S = 1,2,3,5,7,4,4,10,11,12
    T = 3,1,2,9,6,4,10,5,9

I want to find biggest sub-sequence of this streams such that they will be same by some sort of rearrangement, for example in this case `1,2,3` in first and 3,1,2 in second stream, can be converted to each other by rearrangement, and seems it's largest (with length 3).

Any idea well come, and sure it's not my homework and I try it and found O(n^2) algorithm which is not easy to say (at least I can't describe it now), but I want to get your ideas to see is possible to apply it to current algorithm or not, don't care if you can't find better than O(n^2) or O(n^2) but if anyone found better I'll allocate max bounty for the answer also sure for your nice idea. 
Longest common subsequence by allowing re arrangement of common parts
===

Assume we have to char stream like:

    S = 1,2,3,5,7,4,4,10,11,12
    T = 3,1,2,9,6,4,10,5,9

I want to find biggest sub-sequence of this streams such that they will be same by some sort of rearrangement, for example in this case `1,2,3` in first and 3,1,2 in second stream, can be converted to each other by rearrangement, and seems it's largest (with length 3).

Any idea well come, and sure it's not my homework and I try it and found O(n^2) algorithm which is not easy to say (at least I can't describe it now), but I want to get your ideas to see is possible to apply it to current algorithm or not, don't care if you can't find better than O(n^2) or O(n^2) but if anyone found better I'll allocate max bounty for the answer also sure for your nice idea. 