剑指offer
调整数组顺序使奇数位于偶数前面
相似的企业真题
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 64M,其他语言128M
热度指数:878267
本题知识点:
数组
算法知识视频讲解
校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
题目描述
输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。
上一题
登录
/
注册
我的提交
编辑器加载中...
public class Solution { public void reOrderArray(int [] array) { } }
class Solution { public: void reOrderArray(vector
&array) { } };
# -*- coding:utf-8 -*- class Solution: def reOrderArray(self, array): # write code here
class Solution { public int[] reOrderArray(int[] array) { // write code here } }
function reOrderArray(array) { // write code here } module.exports = { reOrderArray : reOrderArray };
function reOrderArray(array) { // write code here }
# # # @param array int整型一维数组 # @return int整型一维数组 # class Solution: def reOrderArray(self , array ): # write code here
package main /** * * @param array int整型一维数组 * @return int整型一维数组 */ func reOrderArray( array []int ) []int { // write code here }
/** * * @param array int整型一维数组 * @param arrayLen int array数组长度 * @return int整型一维数组 * @return int* returnSize 返回数组行数 */ int* reOrderArray(int* array, int arrayLen, int* returnSize ) { // write code here }