0491-0500

491. Increasing Subsequences $\star\star$

492. Construct the Rectangle $\star$

493. Reverse Pairs $\star\star\star$

494. Target Sum $\star\star$

495. Teemo Attacking $\star\star$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class Solution {
 public:
  int findPoisonedDuration(vector<int>& timeSeries, int duration) {
    if (timeSeries.empty() || duration == 0) return 0;

    int ans = 0;

    for (int i = 0; i + 1 < timeSeries.size(); ++i)
      ans += min(timeSeries[i + 1] - timeSeries[i], duration);

    return ans + duration;
  }
};

496. Next Greater Element I $\star$

497. Random Point in Non-overlapping Rectangles $\star\star$

498. Diagonal Traverse $\star\star$

499. The Maze III $\star\star\star$

500. Keyboard Row $\star$