LeetCode题解之Valid Triangle Number

时间:2021-01-13 19:46:01

1、题目描述

LeetCode题解之Valid Triangle Number

2、问题分析

暴力计算

3、代码

  int triangleNumber(vector<int>& nums) {
int res =;
if( nums.size() < )
return res; for( int i = ; i < nums.size() -; i++){
for( int j = i+; j < nums.size()-; j++){
for( int k = j +; k < nums.size(); k++){
if( isTri(nums[i], nums[j], nums[k]) )
res ++;
}
}
} return res; } bool isTri(int a ,int b, int c){
if( a+b<=c || b+c <= a || a+c<=b || a <= ||b <= ||c <= )
return false;
else
return true;
}