Open yokostan opened 5 years ago
This is super amazing:
class Solution { public void wiggleSort(int[] nums) { if (nums == null) return ; for (int i = 1; i < nums.length; i++) { if (i % 2 == 1 != nums[i] >= nums[i - 1]) { int temp = nums[i]; nums[i] = nums[i - 1]; nums[i - 1] = temp; } } } }
This line if (i % 2 == 1 != nums[i] >= nums[i - 1]) is genius in that it contains two conditions in the same line!!
if (i % 2 == 1 != nums[i] >= nums[i - 1])
This is super amazing:
This line
if (i % 2 == 1 != nums[i] >= nums[i - 1])
is genius in that it contains two conditions in the same line!!