Given a string: "This is a sample string", the task at hand is to split it into 2 strings without breaking any words. The goal is to create two strings with the closest length possible, resulting in:
["This is a", "sample string"].
For example:
"Gorge is nice" => ["Gorge", "is nice"]
It would also be helpful if the function could accept the number of elements as a parameter and provide the desired result accordingly.
Appreciate any assistance provided!