0601-0610

601. Human Traffic of Stadium \star\star\star

602. Friend Requests II: Who Has the Most Friends \star\star

603. Consecutive Available Seats \star

604. Design Compressed String Iterator \star

605. Can Place Flowers \star

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class Solution {
 public:
  bool canPlaceFlowers(vector<int>& flowerbed, int n) {
    for (int i = 0; i < flowerbed.size(); ++i) {
      if (flowerbed[i] == 0 && (i == 0 || flowerbed[i - 1] == 0) &&
          (i == flowerbed.size() - 1 || flowerbed[i + 1] == 0)) {
        flowerbed[i] = 1;
        --n;
      }
      if (n <= 0) return true;
    }

    return false;
  }
};

606. Construct String from Binary Tree \star

607. Sales Person \star

608. Tree Node \star\star

609. Find Duplicate File in System \star\star

610. Triangle Judgement \star