python3才有语法 arr.copy(),python2里使用 arr[:] 复制
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param array int整型一维数组 # @return int整型一维数组 # class Solution: def reOrderArray(self , array ): # write code here oddNum = 0 for i in array: if i % 2 != 0: oddNum += 1 copy = array.copy() i = 0 j = oddNum for num in copy: if num % 2 == 1: array[i] = num i += 1 else: array[j] = num j+=1 return array