题目描述
Convert a given string to its cross string (i.e Diagonal from left-right and from right-left).
See examples for better understanding.
Example 1:
Input:
abc
Output:
a c b a c
Explanation:
The above is the proper
cross manner for the
test case.
a c
b
a c
Example 2:
Input:
geeks
Output:
g s e k e e k g s
Explanation:
For the 1st test case where
the string is geeks
G S
E K
E
E K
G S
The above is the proper cross
the manner for the test case, but
when printed in a single line
it becomes as shown in the output.
Your Task:
You don't need to read input or print anything. Your task is to complete the function crossPattern() which takes the string S and returns a single string in the following way first-line output of the string concatenated with 2nd line and so on till the Nth line.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ length of string ≤ 1000
输入格式
见题面
输出格式
见题面