Given a string a and b that consist of exactly the same characters, determine the minimum “cuts” required on string a such that it is possible to rearrange the segments of string a to match string b,
For instance, if a = “xxyyz” and b = “zxyxy”, the minimum cuts required on string a is 3
Illustration: x | xy | y | z --> z-xy-x-y
Constraints: |a| = |b| <= 20.
Time limit: 1 second