题目地址
LeetCode#611 Valid Triangle Number
题目描述
Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.
Example 1:
1 | Input: [2,2,3,4] |
Note:
- The length of the given array won’t exceed 1000.
- The integers in the given array are in the range of [0, 1000].
解题思路
emmmm判断三条边能否构成三角形的计算应该不需要解释了,我们无脑的使用三层循环就可以 AC ,不过时间复杂度比较高。
解题代码
1 | class Solution { |