Created
April 28, 2019 05:06
-
-
Save sujitmhj/bb3a9efaf7fd35f6c11a06f1fa9950cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# you can write to stdout for debugging purposes, e.g. | |
# print("this is a debug message") | |
def check_triangle(numbs): | |
total = sum(numbs) | |
for i in range(3): | |
item = numbs[i] | |
two_sum = total - item | |
if item >= two_sum: | |
return False | |
return True | |
def solution(A): | |
# 1, 2, 3, 4, 5, 6 | |
if len(A) < 3: | |
return 0 | |
A = sorted(A) | |
for i in range(len(A)-2): | |
if check_triangle(A[i:i+3]): | |
return 1 | |
return 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment