Offer prove safety [13]. Adjusting the even order of the array so that the front of python odd implemented

Description Title
input an array of integers, to realize a function to adjust the order of the numbers in the array, such that all the odd part of the front half of the array, the array is located in the second half of all even and ensure between odd and even, odd and even the relative positions unchanged.

# -*- coding:utf-8 -*-
class Solution:
    def reOrderArray(self, array):
        # write code here
        a = []
        b = []
        for i in array:
            if i % 2 != 0:
                a.append(i)
            else:
                b.append(i)
        return a+b
Published 99 original articles · won praise 6 · views 4003

Guess you like

Origin blog.csdn.net/weixin_42247922/article/details/103911382