1、 Title Description

2、 Problem analysis

Calculation of violence

3、 Code

 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;
}

LeetCode How to solve the problem Valid Triangle Number More articles about

  1. LeetCode 611. The number of effective triangles (Valid Triangle Number)

    611. The number of effective triangles 611. Valid Triangle Number Title Description LeetCode LeetCode LeetCode611. Valid Triangle Number secondary ...

  2. Leetcode And Valid Triangle Number

    611. Valid Triangle Number 1.Problem Given an array consists of non-negative integers, your task is ...

  3. leetcode 611. Valid Triangle Number 、259. 3Sum Smaller(lintcode 918. 3Sum Smaller)

    The two questions are almost the same , Just say 611. Valid Triangle Number Satisfy more than conditions ,259. 3Sum Smaller Satisfy less than condition , Both are sorted first , And then with a double pointer . 611. Valid T ...

  4. LeetCode Answer key 593. Valid Square (Medium)

    LeetCode Answer key 593. Valid Square (Medium) Judge the given four points , Whether it can form a square https://leetcode.com/problems/valid-squa ...

  5. LeetCode Valid Triangle Number

    The link to the original question is here :https://leetcode.com/problems/valid-triangle-number/description/ subject : Given an array consists ...

  6. [LeetCode] Valid Triangle Number The number of legal triangles

    Given an array consists of non-negative integers, your task is to count the number of triplets chose ...

  7. LeetCode 611. Valid Triangle Number The number of effective triangles (C++)

    subject : Given an array consists of non-negative integers, your task is to count the number of triplets c ...

  8. 【leetcode】Valid Triangle Number

    subject : Given an array consists of non-negative integers, your task is to count the number of triplets c ...

  9. [Swift]LeetCode611. The number of effective triangles | Valid Triangle Number

    Given an array consists of non-negative integers, your task is to count the number of triplets chose ...

Random recommendation

  1. oracle linux start-up

    [oracle@dg1 ~]$ sqlplus /nolog SQL*Plus: Release 10.2.0.1.0 - Production on Mon May 11 12:51:24 2009 ...

  2. get New skills : How to set the height and width of an element to a specific ratio . Width change , The height automatically changes proportionally . For example, setting the aspect ratio 16:9.

    Setting the aspect ratio is useful in many cases . The chestnuts below , We set the aspect ratio of a container as 16:9 //HTML code snippet <div class="container"> <div c ...

  3. html title _ The paragraph _ Line break _ Level _ Special characters

    title <h1> First level title </h1> <h2 align=" Alignment mode "> Secondary title </h2> The alignment is left,center,right ...

  4. javascript data type Variable Type conversion operators

    data type : 1. character string ( What is contained in double quotation marks ), decimal , Integers , Date time , Boolean, etc . 2. Variable : It's all generic var,     Define a variable format :var a: 3. Type conversion : Divided into automatic conversion and cast , commonly ...

  5. Is it possible to configure PostgreSQL to automatically close idle connections?

    1.use pgbouncer As new connections/transactions/statements arrive, the pool will increase in size up ...

  6. C Language grammar Change

    < Program > ->  < External statement > |  < Program >  < External statement > < External statement >  ->   < Function definition >  |  &l ...

  7. max_connections And max_used_connections --ERROR 1040: Too many connections

    mysql> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value ...

  8. Encountered in the project about CSS Overflow Hidden stay iPhone &amp; Safari It doesn't work

    Debugging for half a day <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <m ...

  9. python The way (3) Functions and anonymous functions

    function Function and process The process def test(): " notes " print('1 am chen') test() : Procedure call def : Define keywords for functions test : Function name pr ...

  10. Py Student information management system Case study ( Optimized version )

    # The first question is : Design a global variable , To save a lot of student information : Student ( Student number , full name , Age ): Think about the structure to preserve :# The second question is : On the basis of the first question , complete : Let the user enter a new student information ( Student number , full name , Age ): You keep it in ...