0411-0420

411. Minimum Unique Word Abbreviation $\star\star\star$

412. Fizz Buzz $\star$

413. Arithmetic Slices $\star\star$

414. Third Maximum Number $\star$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Solution {
 public:
  int thirdMax(vector<int>& nums) {
    priority_queue<int, vector<int>, compare> pq;
    unordered_set<int> set;

    for (int num : nums)
      if (!set.count(num)) {
        set.insert(num);
        pq.push(num);
        if (pq.size() > 3) pq.pop();
      }

    if (pq.size() == 2) pq.pop();

    return pq.top();
  }

 private:
  struct compare {
    bool operator()(const int a, const int b) { return a > b; }
  };
};

415. Add Strings $\star$

416. Partition Equal Subset Sum $\star\star$

417. Pacific Atlantic Water Flow $\star\star$

418. Sentence Screen Fitting $\star\star$

419. Battleships in a Board $\star\star$

420. Strong Password Checker $\star\star\star$