Skip to content

Commit

Permalink
Update wiggle-sort-ii.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
kamyu104 committed Jan 1, 2016
1 parent bf549cd commit 3180b1c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion C++/wiggle-sort-ii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class Solution {

void dutchFlagSort(vector<int>& nums, int val) {
#define Nums(i) nums[(1 + 2 * (i)) % N]
for (int i = 0, j = 0, n = nums.size() - 1, N = nums.size() + n % 2; j <= n;) {
const int N = nums.size() % 2 ? nums.size() : nums.size() + 1;
for (int i = 0, j = 0, n = nums.size() - 1; j <= n;) {
if (Nums(j) > val) {
swap(Nums(i++), Nums(j++));
} else if (Nums(j) < val) {
Expand Down

0 comments on commit 3180b1c

Please sign in to comment.