![]() |
VOOZH | about |
Given three strings str, A and B. The task is to check whether str = A + B or str = B + A where + denotes concatenation.
Examples:
Input: str = "GeeksforGeeks", A = "Geeksfo", B = "rGeeks"
Output: Yes
str = A + B = "Geeksfo" + "rGeeks" = "GeeksforGeeks"
Input: str = "Delhicapitals", B = "Delmi", C = "capitals"
Output: No
Approach:
Below is the implementation of the above approach:
Yes
Time Complexity: O(max(a,b,c)), as we are using a loop to traverse a, b, and c times. Where a, b, and c are the length of the strings.
Auxiliary Space: O(1), as we are not using any extra space.