0321-0330

321. Create Maximum Number $\star\star\star$

322. Coin Change $\star\star$

323. Number of Connected Components in an Undirected Graph $\star\star$

324. Wiggle Sort II $\star\star$

325. Maximum Size Subarray Sum Equals k $\star\star$

326. Power of Three $\star$

327. Count of Range Sum $\star\star\star$

328. Odd Even Linked List $\star\star$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Solution {
 public:
  ListNode* oddEvenList(ListNode* head) {
    if (!head) return NULL;

    ListNode dummyOdd(0);
    ListNode dummyEven(0);
    ListNode* prevOdd = &dummyOdd;
    ListNode* prevEven = &dummyEven;
    int index = 0;

    while (head) {
      auto next = head->next;
      head->next = NULL;
      if (index++ & 1) {
        prevEven->next = head;
        prevEven = head;
      } else {
        prevOdd->next = head;
        prevOdd = head;
      }
      head = next;
    }
    prevOdd->next = dummyEven.next;

    return dummyOdd.next;
  }
};

329. Longest Increasing Path in a Matrix $\star\star\star$

330. Patching Array $\star\star\star$