剑指offer 21.57.58Ⅰ. 双指针(简单)
27.
题目:
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面https://leetcode-cn.com/problems/diao-zheng-shu-zu-shun-xu-shi-qi-shu-wei-yu-ou-shu-qian-mian-lcof/
想法:双指针分别从头尾判断两数的奇偶,往中间移动或交换
class Solution {
public int[] exchange(int[] nums) {
int i=0;
int j=nums.length-1;
while(i
共有 0 条评论