0951-0960

951. Flip Equivalent Binary Trees $\star\star$

952. Largest Component Size by Common Factor $\star\star\star$

953. Verifying an Alien Dictionary $\star$

954. Array of Doubled Pairs $\star\star$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
class Solution {
 public:
  bool canReorderDoubled(vector<int>& A) {
    unordered_map<int, int> count;
    for (int a : A) ++count[a];

    sort(A.begin(), A.end(), [](int a, int b) { return abs(a) < abs(b); });

    for (int a : A) {
      if (count[a] == 0) continue;
      if (count[2 * a] == 0) return false;
      --count[a];
      --count[2 * a];
    }

    return true;
  }
};

955. Delete Columns to Make Sorted II $\star\star$

956. Tallest Billboard $\star\star\star$

957. Prison Cells After N Days $\star\star$

958. Check Completeness of a Binary Tree $\star\star$

959. Regions Cut By Slashes $\star\star$

960. Delete Columns to Make Sorted III $\star\star\star$