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

Difficulty: EASY
Tags: String algorithms

Data structures
Skill types: Data structures
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3
class Solution:
    def crossPattern (ob,S):
        # code here 

Solutions:
class Solution:

	def crossPattern(ob, S):
		start = ''
		end = ''
		n = len(S)
		for i in range(n // 2):
			row = i * ' ' + S[i] + (n - 2 * (i + 1)) * ' ' + S[-i - 1] + i * ' '
			start += row
			end = row + end
		if n % 2:
			start += n // 2 * ' ' + S[n // 2] + n // 2 * ' '
		return start + end


class Solution:

	def crossPattern(ob, S):
		len1 = len(S)
		ans = ''
		for i in range(0, len1):
			j = len1 - 1 - i
			for k in range(0, len1):
				if k == i or k == j:
					ans += S[k]
				else:
					ans += ' '
		return ans


import math

class Solution:

	def crossPattern(ob, S):
		result = []
		s = S
		size = len(s)
		iterate = math.ceil(size / 2)
		for i in range(iterate):
			result.append(' ' * i)
			result.append(s[i])
			result.append(' ' * (size - i - 1 - i - 1))
			if i != size - i - 1:
				result.append(s[size - i - 1])
				result.append(' ' * i)
			else:
				result.append(' ' * i)
		if size % 2 != 0:
			iterate = iterate - 1
		for i in reversed(range(iterate)):
			result.append(' ' * i)
			result.append(s[i])
			result.append(' ' * (size - i - 1 - i - 1))
			if i != size - i - 1:
				result.append(s[size - i - 1])
				result.append(' ' * i)
			else:
				result.append(' ' * i)
		return ''.join(result)


class Solution:

	def crossPattern(ob, S):
		start = 0
		end = len(S) - 1
		ans = []
		for i in range(len(S)):
			for j in range(len(S)):
				if j == start:
					ans.append(S[start])
				elif j == end:
					ans.append(S[j])
				else:
					ans.append(' ')
			start += 1
			end -= 1
		return ''.join(ans)


class Solution:

	def crossPattern(ob, S):
		i = 0
		n = len(S)
		t = ''
		while i < n:
			l = [' ' for j in range(n)]
			l[i] = S[i]
			l[n - 1 - i] = S[n - 1 - i]
			t += ''.join(l)
			i += 1
		return t


class Solution:

	def crossPattern(ob, ip):
		s = ''
		for i in range(len(ip)):
			result = ''
			for j in range(len(ip)):
				if i == j:
					result = result + ip[i]
				elif j == len(ip) - i - 1:
					result = result + ip[j]
				else:
					result = result + ' '
			s += result
		return s


class Solution:

	def crossPattern(ob, st):
		n = len(st)
		if n % 2 == 0:
			ans = ''
			for i in range(n // 2):
				ans += ' ' * i + st[i] + (n // 2 - i - 1) * '  ' + st[n - 1 - i] + ' ' * i
			for i in range(n // 2 - 1, -1, -1):
				ans += ' ' * i + st[i] + (n // 2 - i - 1) * '  ' + st[n - 1 - i] + ' ' * i
			return ans
		else:
			ans = ''
			for i in range(n // 2):
				ans += ' ' * i + st[i] + (n // 2 - i - 1) * '  ' + ' ' + st[n - 1 - i] + ' ' * i
			ans += ' ' * (n // 2) + st[n // 2] + ' ' * (n // 2)
			for i in range(n // 2 - 1, -1, -1):
				ans += ' ' * i + st[i] + (n // 2 - i - 1) * '  ' + ' ' + st[n - 1 - i] + ' ' * i
			return ans
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		S = str(input())
		ob = Solution()
		print(ob.crossPattern(S))


class Solution:

	def crossPattern(ob, s):
		a = ''
		for i in range(len(s)):
			for j in range(len(s)):
				if i == j or i + j == len(S) - 1:
					a = a + s[j]
				else:
					a = a + ' '
		return a


class Solution:

	def crossPattern(ob, S):
		n = len(S)
		t = ''
		m = [[' ' for j in range(n)] for i in range(n)]
		l = 0
		h = n - 1
		for i in range(n):
			for j in range(n):
				if i == j:
					m[i][j] = S[l]
					l += 1
				if i + j + 1 == n:
					m[i][j] = S[h]
					h -= 1
		for i in range(n):
			for j in range(n):
				t += m[i][j]
		return t


class Solution:

	def crossPattern(ob, S):
		string = ''
		for i in range(0, len(S)):
			for j in range(0, len(S)):
				if i == j or i + j == len(S) - 1:
					string += S[j]
				else:
					string += ' '
		return string


class Solution:

	def crossPattern(ob, S):
		dp = [[' ' for i in range(len(S))] for j in range(len(S))]
		for i in range(len(S)):
			dp[i][i] = S[i]
		(start, end) = (len(S) - 1, 0)
		while start != -1 and end != len(S):
			dp[start][end] = S[end]
			end += 1
			start -= 1
		ans = ''
		for i in dp:
			ans += ''.join(i)
		return ans


class Solution:

	def crossPattern(ob, S):
		l = []
		for i in range(1, len(S) + 1):
			for j in range(1, len(S) + 1):
				if i == j or i + j == len(S) + 1:
					l.append(S[j - 1])
				else:
					l.append(' ')
		return ''.join(l)


class Solution:

	def crossPattern(ob, S):
		n = len(S)
		res = ''
		for i in range(n):
			for j in range(n):
				if i == j or i + j == n - 1:
					res += S[j]
				else:
					res += ' '
		return res


class Solution:

	def crossPattern(ob, s):
		n = len(s)
		res = [[' '] * n for i in range(n)]
		ans = ''
		for i in range(n):
			res[i][i] = res[n - 1 - i][i] = s[i]
		for i in res:
			ans += ''.join(i)
		return ans


class Solution:

	def crossPattern(ob, s):
		n = len(s)
		m = ''
		for i in range(n):
			for j in range(n):
				if i == j:
					m += s[i]
				elif i + j == n - 1:
					m += s[j]
				else:
					m += ' '
		return m


class Solution:

	def crossPattern(o, S):
		ans = ''
		n = len(S)
		for i in range(n):
			j = n - 1 - i
			for k in range(n):
				if k == i or k == j:
					ans += S[k]
				else:
					ans += ' '
		return ans


class Solution:

	def crossPattern(ob, S):
		n = len(S)
		l = [' '] * n * n
		st1 = 0
		st2 = n - 1
		ind1 = 0
		ind2 = n - 1
		for i in range(n * n):
			if i == st1:
				l[i] = S[ind1]
				st1 += n + 1
				ind1 += 1
			if i == st2:
				l[i] = S[ind2]
				st2 += n - 1
				ind2 -= 1
		x = ''
		for i in l:
			x = x + i
		return x


class Solution:

	def crossPattern(ob, s):
		n = len(s)
		a = ''
		x = 0
		for i in range(n):
			for j in range(n):
				if i == j or i + j == n - 1:
					a += s[j]
				else:
					a += ' '
		return a


class Solution:

	def crossPattern(ob, S):
		n = len(S)
		m = 2 * n - 1
		res = ''
		x = 0
		for i in range(n):
			for j in range(n):
				if i == j or i + j == n - 1:
					res += S[j]
				else:
					res += ' '
		return res


class Solution:

	def crossPattern(ob, S):
		n = len(S)
		st = ''
		for row in range(n):
			for col in range(n):
				if row == col or row + col == n - 1:
					st = st + S[col]
				else:
					st = st + ' '
		return st


class Solution:

	def crossPattern(ob, S):
		n = len(S)
		a = []
		for i in range(n):
			k = []
			for j in range(n):
				s = ' '
				k.append(s)
			a.append(k)
		j = 0
		k = 0
		kk = n - 1
		p = n - 1
		for i in range(n):
			if i == j:
				a[i][j] = S[k]
			a[i][p] = S[kk]
			p -= 1
			k += 1
			j += 1
			kk -= 1
		res = ''
		for i in range(n):
			for j in range(n):
				res += a[i][j]
		return res