标签:logs family else length .so font 排序 ++ ret
public class Solution { public void wiggleSort(int[] nums) { int n = nums.length; if(n == 0) return ; int[] a = Arrays.copyOfRange(nums,0,n); Arrays.sort(a); int k = 0 , p = (n-1)/2, q = n-1; boolean sign = true;
//sign控制交替赋值 while(k < n){ if(sign) nums[k++]=a[p--]; else nums[k++]=a[q--]; sign = !sign; } } }
标签:logs family else length .so font 排序 ++ ret
原文地址:http://www.cnblogs.com/team42/p/6901295.html