0611-0620

611. Valid Triangle Number $\star\star$

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

    sort(nums.begin(), nums.end());

    for (int k = nums.size() - 1; k > 1; --k)
      for (int i = 0, j = k - 1; i < j;) {
        if (nums[i] + nums[j] > nums[k]) {
          ans += j - i;
          --j;
        } else
          ++i;
      }

    return ans;
  }
};

612. Shortest Distance in a Plane $\star\star$

613. Shortest Distance in a Line $\star$

614. Second Degree Follower $\star\star$

615. Average Salary: Departments VS Company $\star\star\star$

616. Add Bold Tag in String $\star\star$

617. Merge Two Binary Trees $\star$

618. Students Report By Geography $\star\star\star$

619. Biggest Single Number $\star$

620. Not Boring Movies $\star$