思路就是三重循环遍历即可,反正不卡时间复杂度(逃
class Solution { public: int triangleNumber(vector<int>& nums) { int count = 0; for(int i = 0; i < nums.size(); i++) for(int j = i+1; j<nums.size(); j++) for(int k = j + 1; k < nums.size(); k++){ if((nums[i] + nums[j] > nums[k]) && (nums[k] + nums[j] > nums[i]) && (nums[k] + nums[i] > nums[j])) count++; } return count; } };