human
Positive elements at even and negative at odd positions ( Relative order not maintained ) | Python 3 program to rearrange positive and negative numbers.
Move forward the positive pointer till negative number number not encountered.
Move forward the negative pointer till positive number number not encountered.
Swap array elements to fix their position ..
Break from the while loop when any index exceeds the size of the array.
Driver code"
Solution in Python:
 Give me a code to positive elements at even and negative at odd positions ( Relative order not maintained ) and the other steps required?
assistant
#Here is code to positive elements at even and negative at odd positions ( Relative order not maintained ) and the other steps required.
 def rearrange ( a , size ) :
	positive = 0
	negative = 1
	while ( True ) :
		while ( positive < size and a [ positive ] >= 0 ) :
			positive = positive + 2
		while ( negative < size and a [ negative ] <= 0 ) :
			negative = negative + 2
		if ( positive < size and negative < size ) :
			temp = a [ positive ]
			a [ positive ] = a [ negative ]
			a [ negative ] = temp
		else :
			break
arr = [ 1 , - 3 , 5 , 6 , - 3 , 6 , 7 , - 4 , 9 , 10 ]
n = len ( arr )
rearrange ( arr , n )
for i in range ( 0 , n ) :
	print ( arr [ i ] , end = " ▁ " )