题目:输入一个整数数组,调整数组中数字的顺序,使得所有偶数位于数组的前半部分,
所有奇数位于数组的后半部分。要求时间复杂度为O(n)。
def Switch(m):
s=0;
e=len(m)-1;
while s<=e:
if m[s]%2!=1:
s+=1
continue
if m[e]%2!=0:
e-=1
continue
if m[s]%2==1 and m[e]%2==0:
m[s],m[e]=m[e],m[s]
return m
a=[1,2,3,5,3,6,7,8,9]
Switch(a)
print a