Print a Y shaped pattern from asterisks in N number of lines.
Note:
1. N is even.
2. All the strings in the string array which you will return is of length N, so add the spaces wherever required, so that the length of every string becomes N.
 
Example 1:
Input:
N = 4
Output:
*   * 
 * *  
  *    
  *
Example 2:
Input:
N = 8
Output:
*       *
 *     * 
  *   *  
   * *   
    *
    *
    *
    *
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function yShapedPattern() which takes an Integer N as input and returns a vector of strings where each line represents lines of the pattern. For example, if N = $, the vector v = {"*   *", " * * ", "  *  ","  *  "}.
 
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
 
Constraints:
4 <= N <= 200

Difficulty: EASY
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)

Starter code:
#User function Template for python3



class Solution:

    def yShapedPattern(self, N):

        # code here 

Solutions:
class Solution:

	def yShapedPattern(self, N):
		k = 0
		s = N - 1
		if N // 2 == 1:
			s = 1
		y = ''
		for i in range(0, N // 2):
			y = y + ' ' * k + '*' + ' ' * s + '*' + '\n'
			k = k + 1
			s = s - 2
		if N % 2 == 0:
			for i in range(0, N // 2 - 1):
				y = y + (' ' * (N // 2) + '*' + '\n')
			y = y + (' ' * (N // 2) + '*')
		else:
			for i in range(0, N // 2):
				y = y + (' ' * (N // 2) + '*' + '\n')
			y = y + (' ' * (N // 2) + '*')
		return y


class Solution:

	def yShapedPattern(self, N):
		if N % 2 != 0:
			N = N + 1
		ans = ''
		for i in range(N):
			s = ''
			for j in range(N + 1):
				if i < N / 2:
					if j == i or j == N - i:
						s = s + '*'
					else:
						s = s + ' '
				elif j == N / 2:
					s = s + '*'
				else:
					s = s + ' '
			if i == N - 1:
				ans = ans + s
			else:
				ans = ans + s + '\n'
		return ans


class Solution:

	def yShapedPattern(self, N):
		c = 0
		n = N - 1
		for i in range(N // 2):
			t = c * ' ' + '*' + n * ' ' + '*'
			c += 1
			n = n - 2
			print(t)
		d = N // 2
		for i in range(d - 1):
			print(d * ' ' + '*')
		return d * ' ' + '*'


class Solution:

	def yShapedPattern(self, N):
		ans = ''
		spaces = N - 1 if N & 1 != 1 else N - 2
		endSpaces = 0
		while spaces > 0:
			a = ''
			for i in range(endSpaces):
				a += ' '
			a += '*'
			for i in range(spaces):
				a += ' '
			a += '*'
			for i in range(endSpaces):
				a += ' '
			ans += a
			ans += '\n'
			endSpaces += 1
			spaces -= 2
		a = ''
		num = N // 2 if N & 1 != 1 else N // 2 + 1
		for i in range(N // 2):
			a += ' '
		a += '*'
		for i in range(N // 2):
			a += ' '
		for i in range(num):
			ans += a
			if i < num - 1:
				ans += '\n'
		return ans
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.yShapedPattern(N))


class Solution:

	def yShapedPattern(self, N):
		k = 0
		for i in range(N // 2):
			print(' ' * k + '*' + ' ' * (N - 1 - k * 2) + '*')
			k += 1
		for i in range(N // 2 - 1):
			print(' ' * (N // 2) + '*')
		return ' ' * (N // 2) + '*'
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.yShapedPattern(N))


class Solution:

	def yShapedPattern(self, N):
		c = 0
		for i in range(N // 2):
			print(' ' * i + '*', end='')
			print(' ' * (N - 1 - c) + '*')
			c += 2
		for j in range(N // 2 - 1):
			print(' ' * (N // 2) + '*')
		return ' ' * (N // 2) + '*'


class Solution:

	def yShapedPattern(self, N):
		for i in range(N // 2):
			print(' ' * i + '*' + ' ' * (N - 1 - 2 * i) + '*' + ' ' * i)
		for i in range(0, N // 2 - 1):
			print(' ' * (N // 2) + '*' + ' ' * (N // 2))
		return ' ' * (N // 2) + '*' + ' ' * (N // 2)


class Solution:

	def yShapedPattern(self, N):
		res = []
		for i in range(N // 2):
			s = []
			for j in range(N // 2):
				if i == j:
					s.append('*')
				else:
					s.append(' ')
			s.append(' ')
			for k in range(N // 2 + 1, N + 1):
				if k == N - i:
					s.append('*')
				else:
					s.append(' ')
			res.append(''.join(s))
		for i in range(N // 2):
			s = []
			for k in range(N // 2, N + 1):
				if k == N:
					s.append('*')
				else:
					s.append(' ')
			res.append(''.join(s))
		return '\n'.join(res)