0481-0490

481. Magical String $\star\star$

482. License Key Formatting $\star$

483. Smallest Good Base $\star\star\star$

484. Find Permutation $\star\star$

485. Max Consecutive Ones $\star$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
class Solution {
 public:
  int findMaxConsecutiveOnes(vector<int>& nums) {
    int ans = 0;
    int sum = 0;

    for (int num : nums) {
      if (num == 0)
        sum = 0;
      else {
        sum += num;
        ans = max(ans, sum);
      }
    }

    return ans;
  }
};

486. Predict the Winner $\star\star$

487. Max Consecutive Ones II $\star\star$

488. Zuma Game $\star\star\star$

489. Robot Room Cleaner $\star\star\star$

490. The Maze $\star\star$