0811-0820

811. Subdomain Visit Count $\star$

812. Largest Triangle Area $\star$

813. Largest Sum of Averages $\star\star$

814. Binary Tree Pruning $\star\star$

815. Bus Routes $\star\star\star$

816. Ambiguous Coordinates $\star\star$

817. Linked List Components $\star\star$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class Solution {
 public:
  int numComponents(ListNode* head, vector<int>& G) {
    int ans = 0;
    unordered_set<int> g(G.begin(), G.end());

    while (head) {
      if (g.count(head->val) && (!head->next || !g.count(head->next->val)))
        ++ans;
      head = head->next;
    }

    return ans;
  }
};

818. Race Car $\star\star\star$

819. Most Common Word $\star$

820. Short Encoding of Words $\star\star$