How should I start solving this class problem?

Apr 9, 2016 at 11:02pm
I need to check if it's possible to create 1 specific string from a selection of numbers and letters in another string. Like if I had an "available" string of "AABB12" then would I be able to create string "BA 112". I wouldn't be able to cause there is only one "1".
How do I start solving this problem? What is the logic or point behind this?

Apr 9, 2016 at 11:55pm
It seems like a brute force problem. The point is you try all combinations.

You have a string, convert it to a char and then try to adjust those chars positions until you get the word you wanted.
Last edited on Apr 9, 2016 at 11:56pm
Apr 10, 2016 at 12:45am
You could make a map of available letters in the first string, then when checking the second string count all instances of each letter, and check the map to see if you have that many.
Topic archived. No new replies allowed.