611. Valid Triangle Number

Description:

https://leetcode.com/problems/valid-triangle-number/description/

Algorithm1:

Use for loop for three times.

It works but slow (beats 23.60%)

Code1:

 

Timing & Space:

O(n^3) & O(1)

 

Algorithm2:

 

Code2:

 

Timing & Space:

Time:

Worst: O(n^2)

Best: O(1)

Space: O(1)

Leave a Reply

Your email address will not be published. Required fields are marked *