BuildString
Rookie SRM 18 · 2022-10-10 · by erinn
Problem Statement
You are given a
Return "YES" if it is possible to build the target string, otherwise return "NO".
Constraints
- parts will contain between 1 and 50 elements, inclusive.
- Each element of parts will contain between 1 and 50 uppercase ('A'-'Z') characters, inclusive.
- target will contain between 1 and 50 uppercase ('A'-'Z') characters, inclusive.
{ "TOP", "CODER" }
"TOPCODER"
Returns: "YES"
It's trivial to concatenate the two strings together.
{ "BOTTOM", "CODER" }
"TOPCODER"
Returns: "NO"
This time it won't work.
{ "ISS", "M", "IPPI" }
"MISSISSIPPI"
Returns: "YES"
Notice that we use "ISS" more than once, and that we're not using the parts in order.
{ "A", "B", "C", "D", "R" }
"ABBACADABRA"
Returns: "YES"
{ "A", "B", "C" }
"ABCD"
Returns: "NO"
Submissions are judged against all 9 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class BuildString with a public method string isPossible(vector<string> parts, string target) · 9 test cases · 2 s / 256 MB per case