Connell Sequence is the sequence formed with the first odd number, i.e 1 as its first term. The subsequent terms of the sequence are made up of the first two even numbers, i.e 2 and 4, followed by the next three odd numbers, i.e 5, 7 and 9, followed by the next four even numbers, i.e 10, 12, 14 and 16 and so on …. 
Given an integer n, generate the first n terms of the Connell Sequence.
Example 1:
Input: n = 6
Output: 1 2 4 5 7 9
Explaination: First one odd number. Then 
two even numbers. Then three odd numbers.
 
Example 2:
Input: n = 2
Output: 1 2
Explaination: The sequence consists of first 
odd number then one even number.
 
Your Task:
You do not need to read input or print anything. Your task is to complete the function connellSequence() which takes n as input parmeters and returns a list of integers containing the first n numbers of the Connell sequence.
 
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(n)
 
Constraints:
1 ≤ n ≤ 10^{5}

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(n)

Starter code:
#User function Template for python3



class Solution:

    def connellSequence(self, n):

        # code here

Solutions:
class Solution:

	def connellSequence(self, n):
		temp = 0
		l = []
		flag = 0
		start = 1
		count = 1
		while len(l) < n:
			if temp >= start:
				flag = not flag
				start += 1
				temp = 0
			if flag == 1:
				if count % 2 == 0:
					temp += 1
					l.append(count)
			elif count % 2 == 1:
				temp += 1
				l.append(count)
			count += 1
		return l


class Solution:

	def connellSequence(self, n):
		(a, i, k, l) = ([], 1, 2, 0)
		while l < n:
			k -= 1
			j = 0
			while j < i and l < n:
				a.append(k)
				k += 2
				l += 1
				j += 1
			i += 1
		return a


from math import floor, sqrt

class Solution:

	def connellSequence(self, m):
		a = []
		for n in range(1, m + 1):
			ele = 2 * n - floor((1 + sqrt(8 * n - 7)) / 2)
			a.append(ele)
		return a
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		n = int(input())
		ob = Solution()
		arr = ob.connellSequence(n)
		for i in arr:
			print(i, end=' ')
		print()


class Solution:

	def connellSequence(self, n):
		x = 0
		count = 2
		r = 2
		c1 = 0
		c2 = 0
		l = [1]
		while len(l) < n:
			if x % 2 == 0 and count % 2 == 0 and (c1 < r):
				l.append(count)
				c1 += 1
			elif x % 2 != 0 and count % 2 != 0 and (c2 < r):
				l.append(count)
				c2 += 1
			count += 1
			if c1 == r or c2 == r:
				x += 1
				r += 1
				c1 = 0
				c2 = 0
		return l


import math

class Solution:

	def connellSequence(self, n):
		if n == 0:
			return 0
		else:
			arr = []
			for i in range(1, n + 1):
				n = 2 * i - math.floor((1 + math.sqrt(8 * i - 7)) / 2)
				arr.append(n)
			return arr


class Solution:

	def connellSequence(self, n):
		results = [0]
		sub_length = 1
		sub_counter = 0
		for i in range(n):
			if sub_counter < sub_length:
				if sub_counter == 0:
					results.append(results[-1] + 1)
				else:
					results.append(results[-1] + 2)
				sub_counter += 1
			if sub_counter == sub_length:
				sub_length += 1
				sub_counter = 0
		return results[1:]
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		n = int(input())
		ob = Solution()
		arr = ob.connellSequence(n)
		for i in arr:
			print(i, end=' ')
		print()


class Solution:

	def connellSequence(self, n):
		results = [0]
		sub_length = 1
		sub_counter = 0
		for i in range(n):
			if sub_counter < sub_length:
				if sub_counter == 0:
					results.append(results[-1] + 1)
				else:
					results.append(results[-1] + 2)
				sub_counter += 1
			if sub_counter == sub_length:
				sub_length += 1
				sub_counter = 0
		return results[1:]


class Solution:

	def connellSequence(self, n):
		l = [1]
		leng = 1
		for i in range(2, int(n // 2) + 2):
			s = l[-1] + 1
			if leng > n:
				break
			for j in range(i):
				l.append(s)
				s += 2
				leng += 1
		return l[0:n]


class Solution:

	def connellSequence(self, n):
		if n == 1:
			return [1]
		f = [1, 2]
		c = 1
		d = 0
		i = 2
		while len(f) < n:
			d = d + 1
			if d > c:
				c = d
				d = 0
				i = i + 1
			else:
				i = i + 2
			f.append(i)
		return f


class Solution:

	def connellSequence(self, n):
		r = []
		(count, value, j) = (0, 1, 1)
		for i in range(1, n + 1):
			r.append(j)
			count += 1
			if count == value:
				count = 0
				value += 1
				j += 1
			else:
				j += 2
		return r


class Solution:

	def connellSequence(self, n):
		res = []
		(count, val, j) = (0, 1, 1)
		for i in range(1, n + 1):
			res.append(j)
			count += 1
			if count == val:
				count = 0
				val += 1
				j += 1
			else:
				j += 2
		return res