![]() |
VOOZH | about |
Given two strings and . Create two new strings by exchanging the first half and second half of one of the strings with the first half and second half of the other string respectively.
Examples:
Input : fighter warrior Output :warhter figrior Input :remuneration day Output :dration remuneay
In the first example, fighter is made up of two parts fig and hter. Similarly, warrior is also made up of two parts war and rior. Interchange the first part of both the strings to create two new strings warhter and figrior. Similarly, in the second example first part of remuneration which is remune is exchanged with the first part of day to create dration and remuneay.
Implementation:
remuneay dration
Time Complexity: O(n), time required for substr function
Auxiliary Space: O(n)