Created
April 14, 2015 10:17
-
-
Save stephen-maina/c7cfc512418e16e3ffa2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.util.stream.IntStream; | |
class Solution { | |
public int solution(int[] A) { | |
// write your code in Java SE 8 | |
int[]sorted=IntStream.of(A).sorted().toArray(); | |
for(int index=2;index<sorted.length;index++){ | |
long ind1=(long)sorted[index]; | |
long ind2=(long)sorted[index-1]; | |
long ind3=(long)sorted[index-2]; | |
if(ind3+ind2>ind1&&ind1+ind2>ind3&&ind3+ind1>ind2){ | |
return 1; | |
} | |
} | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment